简体   繁体   中英

fetch facebook user's friends with javascript

I am a new comer of StackOverFlow. As title, I 'd like to pick a subset of the user's friends, and I have tried that in the Graph API Explorer with → /v2.1/ me?fields=friends . However it return an empty json named data and the total count of the user's friends. What did I miss?? Below is my test in the facebook Graph API explorer.. ! Here comes the result in the graph api explorer.

{
    "friends": {
        "data": [
            ], 
        "summary": {
          "total_count": 15
        }
        }, 
    "id": "585768444863088"
}

You can also just use /me/friends instead, but the empty array is correct. You only get those friends who authorized your App too, you don´t get every friend anymore since end of April 2014 (v2.0 of the Graph API).

See here: https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids

  1. /me/friends returns the user's friends who are also using your app

There are ways to get the whole friendlist like invitable_friends and https://developers.facebook.com/docs/graph-api/reference/v2.1/user/taggable_friends , but those endpoints are supposed to get used for very specific tasks (for inviting in games and for tagging).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM