当前位置: 动力学知识库 > 问答 > 编程问答 >

facebook - Fetching list of friends in Graph API or FQL - Appears to be missing some friends

问题描述:

Any chance the 'me/friends' graph api or friends FQL table return some friends only?

I've checked the results and it's slightly less than the count I see on facebook.com

网友答案:

In Graph API V1.0

A call to /friends on a User object (e.g. /me/friends) or a query of the friend FQL table should return all friends of that user except

  1. Those who have deactivated their accounts
  2. Those who have blocked your app
  3. Those who have disabled all Platform apps from accessing their data. - If a user enables this option (see below) you can't access any information about that user via the API, including their basic info, posts they make, etc. They won't appear in the friends list of your app's user via the API.

If you find friends are missing from the response it's almost certainly for one of those reasons, and in my experience most people asking this question are asking about the third case.


The option to remove platform option is currently under Privacy Settings -> Ads, Apps & Websites -> 'Turn off your ability to use apps, plugins, and websites on and off Facebook

If you're not getting all friends in a single call and you're sure it's not because of one of those reasons, check if you have a limit parameter in your query - and increase it if it's less than the number of friends you think should be appearing.

e.g. /me/friends?limit=5000 for the maximum number of friends allowed, 5000

Note that the friends count will include users which can't be retrieved in the list (e.g. the friend_count field of the User FQL table)

In Graph API V2.0 or higher

A call to /friends on a User object will, if the user has granted your app the user_friends permission, return the friends of that user who have also granted your app the user_friends permission -

You can read more about the change from v1.0 to v2.0 in Facebook Graph Api v2.0 me/friends returns empty, or only friends who also use my app or on Facebook's changelog

网友答案:

You need to pass a limit parameter.
'me/friends/?limit=0' it will return all your friends.

UPDATE

the parameter limit=0 returns 0 friends,
to get all your friends, you need to set the limit=5000 (it's the max number allowed)

网友答案:

With the introduction of the Facebook Graph API 2.0, access a user's friends list was removed and limited to just friends who use the same application. However, Facebook added two new APIs to allow retrieval of Friend names (and indirectly a friend count). The two new APIs are taggable_friends and invitable_friends.

Url:
me/taggable_friends?limit=1&fields=id,name,
分享给朋友:
您可能感兴趣的文章:
随机阅读: