【发布时间】:2013-04-07 09:57:12
【问题描述】:
我创建了与 Facebook 集成的应用程序以从中获取信息。我实际上得到了正确的响应,但现在的问题是我无法使用图形 API 获取所有 cmets。假设其中一个帖子有 30 个 cmets,而我使用列表视图仅获取 facebook wall 中每个帖子的最后 2 个 cmets。
请帮助我从帖子中获取所有 cmets。提前致谢。 这是我使用 JSON 解析的代码片段。
childList=new ArrayList<HashMap<String,Object>>();
HashMap<String, Object> childlist_hashMap=new HashMap<String, Object>();
JSONObject comments_Show=data.getJSONObject(i).getJSONObject("comments");
if(comments_Show.has("data"))
{
JSONArray datacomments=comments_Show.getJSONArray("data");
for(int c=0;c<datacomments.length();c++) {
childlist_hashMap=new HashMap<String, Object>();
childlist_hashMap.put("UserName", datacomments.getJSONObject(c).getJSONObject("from").getString("name"));
URL url= new URL("http://graph.facebook.com/"+datacomments.getJSONObject(c).getJSONObject("from").getString("id")+"/picture?type=normal");
childlist_hashMap.put("Image", BitmapFactory.decodeStream(url.openConnection().getInputStream()));
childlist_hashMap.put("CommentsFull",datacomments.getJSONObject(c).getString("message"));
childlist_hashMap.put("Comments_id",datacomments.getJSONObject(c).getString("id"));
childlist_hashMap.put("Comments_date",datacomments.getJSONObject(c).getString("created_time"));
childList.add(childlist_hashMap);
}
}
【问题讨论】: