如何按照共同好友数量的顺序加好友?

发布于 2024-12-10 07:54:35 字数 69 浏览 0 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蹲墙角沉默 2024-12-17 07:54:35

更新

我找不到一种使用图形 API 在一个请求中完成此操作的方法
但可以在 Ruby 中完成,方法是获取好友列表,然后使用 用户上下文,例如这个示例

原始答案

这是要使用的FQL查询仅适用于api版本< v2.1

SELECT uid, mutual_friend_count from user where uid in (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY mutual_friend_count desc

你可以在资源管理器中尝试一下

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

SELECT uid, mutual_friend_count from user where uid in (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY mutual_friend_count desc

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

递刀给你 2024-12-17 07:54:35

理论上,您可以使用以下方法获取用户的朋友列表:

$friendsOfFriend = $facebook->api('/'.$yourFriendsFacebookId.'/friends');

然后您可以检查每个结果以查看他们是否也是您的朋友。

$isMyFriend = $facebook->api('/me/friends/'.$someonesFacebookId);

...并记录计数。

然而我的测试还没有返回任何结果。我尝试获取一些 Facebook 好友的好友,但返回异常:无法查找 {friend's_facebook_ID} 的所有好友。只能查找已登录用户 {my_facebook_ID} 或已登录用户具有适当权限的好友。所以这里可能存在权限问题。

Theoretically, you can get a list of a user's friends using:

$friendsOfFriend = $facebook->api('/'.$yourFriendsFacebookId.'/friends');

Then you can check each of the result to see if they are your friend too.

$isMyFriend = $facebook->api('/me/friends/'.$someonesFacebookId);

... 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.

月下凄凉 2024-12-17 07:54:35

我不认为可以通过 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.

苏大泽ㄣ 2024-12-17 07:54:35

这只是部分答案,因为它们并不都在一个地方,仍然没有找到一种方法将它们放在一个页面上,但它是一个开始,可以通过您的朋友列表以编程方式循环运行...

https://www.facebook.com/browse/mutual_friends/?uid=xxxxxxxxxxxx

因为如果你不提供 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...

https://www.facebook.com/browse/mutual_friends/?uid=xxxxxxxxxxxx

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文