【问题标题】:Unable to get all comments of facebook wall posts using Graph API in android无法在 android 中使用 Graph API 获取 Facebook 墙贴的所有评论
【发布时间】: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);
   }                       
}

【问题讨论】:

    标签: android json facebook


    【解决方案1】:

    我经常听说 Facebook GraphApi 没有提供足够的信息。

    我建议你使用 FQL,更底层的方法来获取数据。 FQL 在this 答案和this 链接中进行了描述。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-16
      • 2014-03-24
      • 1970-01-01
      • 1970-01-01
      • 2013-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多