Get a list of friends of a friend on Facebook

前端 未结 6 1461
耶瑟儿~
耶瑟儿~ 2020-11-27 16:31

I\'ve recently started looking into the Facebook API and am trying to work out how to retrieve the list of friends of another user (in this case the user is someone I\'m fri

相关标签:
6条回答
  • 2020-11-27 17:03

    Once you've got a valid access token for a user, you can query the Graph API with said token and query the "friends" connection of the user object (/me/friends). So if your user ID is "123":

    https://graph.facebook.com/123/friends?access_token=USERS_ACCESS_TOKEN

    You can also use /me to reference the current user:

    https://graph.facebook.com/me/friends?access_token=USERS_ACCESS_TOKEN

    Without a valid access token, you cannot query information about users and access to friends of friends is determined by each user. For example, I cannot see some of my friend's friends:

    Can't lookup all friends of (ID). Can only lookup for the logged in user (ID), or friends of the logged in user with the appropriate permission.

    ...but for some of my other friends, I can. There's probably a permission or flag you can check to see if they allow access, but I'm not currently seeing it.

    0 讨论(0)
  • 2020-11-27 17:15

    Facebook are in the process of deprecating the REST API, and have added equivalent support to the Graph API for this method. You can use Graph API - User object and Get /User_id1/friends/User_id2 to check if User_id1 is friends with User_id2 .

    0 讨论(0)
  • 2020-11-27 17:19

    I figured this out.

    1) The best you can do is find mutual friends
    2) Try using the v1.0 of the Facebook Graph API. v2.0 doesn't have /mutualfriends.
    3) Since I was only interested in my own social network, I grabbed the access token from the graph explorer and wrote a python script to download my whole social network. The code is on github

    0 讨论(0)
  • 2020-11-27 17:22

    You Can only access friends list of logged in user(i.e, your friend list) or the logged in user's friends that are users of your app. i.e, You can access friends friend list only if your friends are the users of your app.

    0 讨论(0)
  • 2020-11-27 17:23

    Yes, its possible to get List of Friends of a friend but only condition is that friend should be user of that application.

    Suppose there is an application "APP" used by "A" then the APP can get his friends List , now you want friends List of "B" who is friend of "A" , it will be possible only if "B" also uses the "APP"

    0 讨论(0)
  • 2020-11-27 17:25

    You can check if two of your friends are friends using friends.are_friends.

    0 讨论(0)
提交回复
热议问题