简体   繁体   中英

Unable to get all comments of facebook wall posts using Graph API in android

I have created my application integrated with Facebook to get feed from that. I actually get the responses properly, but the issue now is that I'm not able to get all comments using graph API. Suppose one of the posts has 30 comments and I'm getting only the last 2 comments of every post in facebook wall using List view.

Please help me to get all comments from the posts. Thanks in advance. This is my Snippet of code using JSON parsing.

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);
   }                       
}

I usually heard that Facebook GraphApi does not give enough information as expected.

I suggest you to use FQL, more lower level method to fetch the data. FQL is described in this answer and this link.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM