如何按照共同好友数量的顺序加好友?
我正在开发一个 Facebook 应用程序。我想知道如何按照共同好友数量的顺序交友。 是否可以使用 FQL 或任何其他方法?
I am developing a Facebook application. I want to know how I can get friends in the order of number of mutual friends.
Is it possible with FQL or any other method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
更新
我找不到一种使用图形 API 在一个请求中完成此操作的方法
但可以在 Ruby 中完成,方法是获取好友列表,然后使用 用户上下文,例如这个示例
原始答案
这是要使用的FQL查询仅适用于api版本< v2.1
你可以在资源管理器中尝试一下
https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20uid%2C%20mutual_friend_count%2C%20friend_cou nt%20from%20user%20where%20uid%20in%20%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%3Dme%28%29%29%20ORDER%20BY%20mutual_friend_count%20desc
Update
I can't find a way to do it in one request using graph API
but it can be done in Ruby by getting friends list then sending request for each friend using User context like this example
Original answer
Here is the FQL query to be used Which is working only for api versions < v2.1
you can try it in the explorer
https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20uid%2C%20mutual_friend_count%2C%20friend_count%20from%20user%20where%20uid%20in%20%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%3Dme%28%29%29%20ORDER%20BY%20mutual_friend_count%20desc
理论上,您可以使用以下方法获取用户的朋友列表:
然后您可以检查每个结果以查看他们是否也是您的朋友。
...并记录计数。
然而我的测试还没有返回任何结果。我尝试获取一些 Facebook 好友的好友,但返回异常:
无法查找 {friend's_facebook_ID} 的所有好友。只能查找已登录用户 {my_facebook_ID} 或已登录用户具有适当权限的好友
。所以这里可能存在权限问题。Theoretically, you can get a list of a user's friends using:
Then you can check each of the result to see if they are your friend too.
... and keep a track of the count.
However my test didn't return any result yet. I attempted to get the friends of some of my facebook friends but it returns an exception:
Can't lookup all friends of {friend's_facebook_ID}. Can only lookup for the logged in user {my_facebook_ID}, or friends of the logged in user with the appropriate permission
. So there might be permission issue here.我不认为可以通过 FQL 获得共同的朋友,因此您必须努力做到这一点:为每个朋友循环调用图形 api 并获取共同朋友的计数。图 api 方法是:/me/mutualfriends/yourFriendsId,您可以一次执行 20 个批量请求以帮助加快速度。如果您能找到一种使用 FQL 来做到这一点的方法,那将是您最快的路线。
I don't think mutual friends are available via FQL so you would have to do this the hard: calling the graph api in a loop for each friend and getting a count of mutual friends. The graph api method is: /me/mutualfriends/yourFriendsId and you could do 20 batch requests at a time to help speed this up. If you can find a way to do this with FQL, that would be your fastest route.
这只是部分答案,因为它们并不都在一个地方,仍然没有找到一种方法将它们放在一个页面上,但它是一个开始,可以通过您的朋友列表以编程方式循环运行...
因为如果你不提供 uid,它会返回一个错误...我只是想在一页上获取所有朋友的列表,但没有骰子。可笑的。
This is only a partial answer as they are not all in one place, still haven't found a way to get them on one page yet, but it is a start, could be run in a loop programmatically through your friend list...
because if you don't give a uid it returns an error... I was just trying to get a list of all my friends on one pagem, but no dice. ridonculous.