如何通过uid统计Facebook用户的好友总数?
如何通过 uid
统计 Facebook 用户的好友总数?
How can I count the total friends of a Facebook user by uid
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何通过 uid
统计 Facebook 用户的好友总数?
How can I count the total friends of a Facebook user by uid
?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
有很多方法可以计算使用 Facebook Graph API 和 Php SDK 的朋友数量,其中之一是我告诉的。
有关完整的教程,请访问这篇文章 获取 FB 好友计数
There are lot of way to count the no of friends using Facebook Graph API with Php SDK, out of one i am telling..
For complete tutorial visit this article Getting FB Friends Count
从
Facebook API 2.0
开始,您无法获取 Facebook 好友的完整列表,仅获取也授权您的应用的好友的部分列表。不过,您仍然可以获得好友总数,Graph API user /friends 有一个字段
summary
,其中包含total_count
计数,因此您可以使用以下方式获取它:
Starting with
Facebook API 2.0
you can't get the full list of Facebook friends, only a partial list of friends that also authorized your app.You can still get the total number of friends though, the Graph API user/friends has a field
summary
containing the count astotal_count
So you can get it using:
这是我的解决方案...效果很好!
将 XXXXXXX152466 替换为 facebook 个人资料 id#
使用 Facebook PHP SDK 以及 Graph API!
Heres my solution... works great!
Replace XXXXXXX152466 with the facebook profile id#
Using Facebook PHP SDK along with Graph API!
FQL 不支持
COUNT
:由于不支持
COUNT
,因此您需要获取所有记录,然后在进行 SQL 调用的任何应用程序中对它们进行计数。如果您想获取更多信息,例如姓名和计数,您可以使用内部选择来获取朋友的扩展信息:
这是一个相关的SO问题:
FQL 结果计数
朋友的参考
COUNT
is not supported by FQL:Since
COUNT
is not supported you need to get all of the records and then count them in whatever application that is making the SQL call.If you want to get more information, like names, along with count you can use an inner select to get the friend's extended info:
Here is a related SO question:
FQL result count
References for Friend table:
自 2014 年 10 月起,FQL 现已弃用。引用 Facebook 的常见问题解答:
用户/朋友端点确实需要 user_friends 权限才能返回使用您的应用程序的朋友的实际列表,但是如果没有授予 user_friends 权限,仍然会返回朋友计数字段。回复示例:
完整常见问题解答:https://developers.facebook.com/docs/apps/faq#total_friend_count
FQL is now deprecated as of October 2014. Quoting Facebook's FAQ :
The user/friends endpoint does require the user_friends permission to return an actual list of friends who use your app, however the friend count field will still be returned without this the user_friends permission granted. Sample response:
Full FAQ: https://developers.facebook.com/docs/apps/faq#total_friend_count
@Scott
这非常有效,我没想到它会:)
https://graph.facebook.com/fql?q=SELECTfriend_count FROM user WHERE uid = 273103345
我尝试使用一个随机用户 ID,该用户 ID 不是 Graph API 中的好友。然而,对于少数随机 uid,它返回 null,我猜它们是页面。
@Scott
This very much works, I didn't expect it to :)
https://graph.facebook.com/fql?q=SELECT friend_count FROM user WHERE uid = 273103345
I tried with a random user id who is not a friend in Graph API. However for few random uids it returned null, I am guessing they were pages.
您可以查询
user
表中有一个friend_count
字段。只需将
me()
替换为您要查询的用户的 UID 即可。There is a
friend_count
field against theuser
table that you can query.Just replace
me()
with the UID of the user that you want to query.