//My API link
//http://gdata.youtube.com/feeds/base/videos?max-results=10&start-//index=1&alt=json&orderby=published&author=astrobixweb
//String Method to fetech data from server
public static String sendRequest(String url) {
String result = "";
try {
HttpClient client = new DefaultHttpClient();
HttpParams httpParameters = client.getParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 5000);
HttpConnectionParams.setSoTimeout(httpParameters, 5000);
HttpConnectionParams.setTcpNoDelay(httpParameters, true);
HttpGet request = new HttpGet();
request.setURI(new URI(url));
HttpResponse response = client.execute(request);
InputStream ips = response.getEntity().getContent();
BufferedReader buf = new BufferedReader(new InputStreamReader(ips,
"UTF-8"));
StringBuilder sb = new StringBuilder();
String s;
while (true) {
s = buf.readLine();
if (s == null || s.length() == 0)
break;
sb.append(s);
}
buf.close();
ips.close();
result = sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
//Here is parser class
public static void GroupResult(String url){
try{
JSONArray jsonarray,jsonArray1,jsonArray2 ;
JSONObject json ;
response=GetJsonObject.sendRequest(url);
//data comes into response variable
if(response == null){
return;
}
jsonarray = new JSONArray("["+response+"]");
json = jsonarray.getJSONObject(0);
String feed = (json.getString("feed"));
Log.v("feed", ""+feed);
//try{
jsonarray = new JSONArray("["+feed+"]");
json = jsonarray.getJSONObject(0);
String entry = json.getString("entry");
jsonarray = new JSONArray(entry);
for (int i = 0; i < jsonarray.length(); i++)
{
mData=new AstrobixData();
json = jsonarray.getJSONObject(i);
String title_array = json.getString("title");
jsonArray1 = new JSONArray("["+title_array+"]");
String title = jsonArray1.getJSONObject(0).getString("$t");
String imagepath=json.getString("content");
jsonArray2=new JSONArray("["+imagepath+"]");
String urliamge=jsonArray1.getJSONObject(0).getString("$t");
}
// mData.SetTitle(title);
// mList.add(mData);
}
}
// Log.v("title", ""+title_list);
}
}
誰かがこの API リンクのデータを取得するのを手伝ってください。私は試してみる必要があり、httpを介して文字列変数のすべてのデータをフェッチする必要があります。しかし、私はこのAPIから2つのことをしたいのですが、これらを取得することはできません:-
- 題名:
"Sun,Moon, Mars, Rahu and Jupiter Antardasha during Sun's Mahadasha"
画像: