错误的共同朋友从facebook算起

时间:2017-05-18 09:12:33

标签: php ruby-on-rails facebook-graph-api

我想从facebook上找到共同的朋友,但它给了我错误的结果。我得到的共同朋友总数是正确的但是当数据是用户不来时

请求

https://graph.facebook.com/v2.8/1744744292507346?fields=context.fields(mutual_friends{name,picture.type(large)})&access_token=access_token

回复

{
   "context": {
      "mutual_friends": {
         "data": [
            {
               "name": "Gaurav Varshney",
               "picture": {
                  "data": {
                     "is_silhouette": false,
                     "url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p200x200/15541198_1872071033026134_3669335060573505093_n.jpg?oh=d4a95ee6cdb8d401be06e8f10fbf6d50&oe=59B0C911"
                  }
               },
               "id": "1919297771636793"
            }
         ],
         "paging": {
            "cursors": {
               "before": "MTkxOTI5Nzc3MTYzNjc5MwZDZD",
               "after": "MTkxOTI5Nzc3MTYzNjc5MwZDZD"
            }
         },
         "summary": {
            "total_count": 2
         }
      },
      "id": "dXNlcl9jb250ZAXh0OgGQHYKW1ALzRNZBAkUhMk2uDFtLZBBkzlasCZAq98zEqnPZBjqy7beHZBJZCVZB7STTw6yMnKC0w4qDA05ZBOGQ3RdRoPjfi1cbAmnChBQ1xLYpJuuKrIEZD"
   },
   "id": "1744744292507346"
}

我只得到一个朋友,因为total_count显示2。可以有人告诉我我做错了吗?我怎么能使用分页?

尝试点击all_mutual_friends时

https://graph.facebook.com/v2.8/1744744292507346?fields=context.fields(all_mutual_friends{name,picture.type(large)})&access_token=access_token

{
   "error": {
      "message": "(#10) To use all_mutual_friends on behalf of people who are not admins, developers and testers of your app, your use of this endpoint must be reviewed and approved by Facebook. To submit this feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review",
      "type": "OAuthException",
      "code": 10,
      "fbtrace_id": "HF3ZO8U3eLW"
   }
}

1 个答案:

答案 0 :(得分:0)

缺乏关于此功能的文档,我不得不深入研究它。主要是关于如何使用Graph API请求。

这就是我正在做的事情,它正在发挥作用,我将在稍后解释一些缺陷:

假设我们在这里有UserA和UserB。您需要收集每个用户的context-id并将其保存在服务器端,因为它必须在以后使用。

因此,UserA连接并希望与已连接的UserB请求共同的朋友。你需要做的是:

UserA FB Graph请求使用:

/'{{UserB context-id}}/all_mutual_friends?limit=5000', 'get'

还发送UserA fbaccesstoken

我使用限制5000来避免对数据结果进行分页。

现在,缺陷:

all_mutual_friends让我有些头疼。当然,我可能完全错了,但我调试了好几天,当功能仍然处于开发模式而不是公共/ FB授权时,似乎Facebook存在一些问题。不知道,我需要请求允许在生产中看到它。

在我的应用程序中,我意识到有时候某些mutual_friends实际上没有列出,并且它不是脚本的错误,但可能是一些用户配置,避免使用这个或一些facebook问题。 IDN。

无论如何,这就是你要求共同朋友的方式。

希望它有所帮助。