//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 获取 String 变量中的所有数据。但我想从这个 API 中得到两件事,但我无法获取这些是:-
- 标题:
"Sun,Moon, Mars, Rahu and Jupiter Antardasha during Sun's Mahadasha"
图片: