4

Main Question:

When I sent a GET request to retrieve data of someID/POSTS, like https://graph.facebook.com/microsoft/posts?fields=comments,likes&limit=1&access_token=, cannot get the "count" in "likes" and "comments" fields using the access token generated by my own facebook registered app, but can get the expected data if using the access token from Facebook Sample apps, e.g. "HelloFacebookSample".

This issue occurs on both Android and FB Graph API Exploer. Also in oder to troubleshoot the possible causes, I used the exactly same codes as FB sample under my registered app_id, but the same problem came out again. So the only possible explanation I can think of is some strange things with FB app_id, not the permission scopes or different users(I've tested using two users).

Here is, the Reponses from GET request of https://graph.facebook.com/microsoft/posts?fields=likes&limit=1&access_token=:

1.Using access_token generated by my app_id:

{
  "data": [
    {
       "id": "20528438720_10151574758413721", 
       "created_time": "2013-07-18T18:41:51+0000", 
       "likes": {
          "data": [
            {
               "id": "701134683", 
               "name": "Someone's name"
            }, 
            {
               "id": "113770258795376", 
               "name": "Someone's name"
            }
            /****and so on****/
        ], 
        "paging": {
         "cursors": {
           "after": "MTAwMDAwNjkxNDMxMTcz", 
           "before": "NzAxMTM0Njgz"
         }, 
         "next": "https://graph.facebook.com/20528438720_10151574758413721/likes?limit=25&after=MTAwMDAwNjkxNDMxMTcz"
       }
     }
   }
  ], 
  "paging": {
    "previous": "https://graph.facebook.com/20528438720/posts?fields=likes&limit=1&since=1374172911", 
    "next": "https://graph.facebook.com/20528438720/posts?fields=likes&limit=1&until=1374172910"
  }
}

2.Using access_token generated by FB's sample app_id(here it can get "count" of likes):

{
  "data": [
      {
        "likes": {
          "data": [
          {
                "name": "Someone's name", 
              "id": "100003531173993"
            }, 
            {
              "name": "Someone's name", 
              "id": "100002299390558"
            }, 
            {
              "name": "Someone's name", 
              "id": "1038509978"
            }, 
            {
              "name": "Someone's name", 
              "id": "1615491698"
            }
          ], 
        "count": 1071
      }, 
      "id": "20528438720_10151574758413721", 
      "created_time": "2013-07-18T18:41:51+0000"
    }
  ], 
  "paging": {
    "previous": "https://graph.facebook.com/20528438720/posts?fields=likes&limit=1&since=1374172911", 
    "next": "https://graph.facebook.com/20528438720/posts?fields=likes&limit=1&until=1374172910"
  }
}

It really confused me for days, and I've done lots of searches, but cannot find any useful or related info perhaps due to my English:P. Did anyone else face the similar problems?

Thank you for reading.

Any help or alternative solution appreciated! (here, I just want to display the number of likes in my app)

4

1 回答 1

7

刚刚自己找到了解决方案,这都是由于 FB 为2013 年 10 月 Breaking Changes迁移。他们更改了 POST_ID/likes 格式,但可能由于尚未完成迁移,因此存在一些不一致之处。以下是我从 Facebook 开发者警报中获得的官方声明。

POST_ID/likes 格式会改变。应用程序将能够通过 paging 检索帖子上的所有喜欢(而不是现在的前 4 个)。由于功能更新,点赞数将移至汇总字段

因此,现在如果您在“赞”或“评论”字段中看不到“计数”,请按照以下步骤操作:

  1. 发送一个 GET 请求,假设https://graph.facebook.com/microsoft/posts?fields=likes&limit=1&access_token=然后你得到 POST_ID = "id"
  2. 一个新的 GET 请求https://graph.facebook.com/POST_ID/likes?summary=true&access_token=,然后你会在“summary”字段中找到“likes”的“total_count”。

希望这可以帮助!

于 2013-07-22T12:59:05.693 回答