How can I count the total friends of a Facebook user by uid
?
相关问题
- facebook error invalid key hash for some devices
- LoginActivty with Firebase & Facebook authenticati
- facebook “could not retrieve data from URL”
- setRequestHeader Content-Type causes POST request
- Sharing to Facebook Stories
相关文章
- Facebook login for group members
- The method FB.api will stop working when called fr
- React native deep linking vs Facebook SDK conflct
- UIActivity with no settings for Facebook
- facebook send API Error Code: 100 API Error Descri
- Can't use Facebook Account Kit: Error inflatin
- Facebook API error subcode 33
- Devise + Omniauth: undefined method `user_omniauth
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:
Heres my solution... works great!
Replace XXXXXXX152466 with the facebook profile id#
Using Facebook PHP SDK along with Graph API!
@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.
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:
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.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