Get a list of friends of a friend on Facebook - facebook

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 friends with).
So far I've only worked out how to find out the friends of a person who I am also friends with. However the Friends Wheel application can do it as you can generate a wheel base on one of your friends, so I'm guessing it is possible.
Anyone know how to do this?

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.

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

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.

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

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"

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 .

Related

Get Facebook Friendlist (only read)

I'm developing an app which is super important to get the user's friends.
I just need to get a list of friends (Avatar and name) I do not require any more information or want to do anything with that data, you simply get a list of friends.
With the new change in Facebook it is impossible?
Regards!
See point 3.) of
https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
/me/friends returns the user's friends who are also using your app
In v2.0, the friends API endpoint returns the list of a person's friends who are also using your app. In v1.0, the response included all of a person's friends.
There are two key use cases where apps need access to non-app friends: tagging and inviting. In v2.0, we've added the Taggable Friends API and the Invitable Friends API to support these flows.

Facebook friends list is empty, just for one specific user

Simply executing this query aiming to list all my friend's friends:
GET https://graph.facebook.com/hisFacebookUserId/friends?return_ssl_resources=1&access_token=hisAccessToken
I obtain an empty data entry. => as if it had 0 friends. (but he has 800).
However, it works for many other users.
What might be the reason?
Since v2.0 of the Facebook API, you can only get the friends who authorized your App too. It´s a (privacy) feature, not a bug.
https://developers.facebook.com/docs/apps/changelog
Also, it´s not necessary to use an ID for the call, because you can only get the friends of the authorized User anyway:
/me/friends
Btw, don´t forget to authorize Users with the user_friends permission.

Accessing Friends List on new FB APIs for non-app users

I am building an app where users can send picture messages to friends and would like users to see their Facebook friends list when they login through FB. However, I am confused by Facebook's new API information regarding the access that an app can have to display someone's list of friends. On the FB change log information page it says:
1) Friend list is no longer part of the default permission set and has its own permission: Asking for access to a person's friend list is now a separate permission that your app must request. The new permission is called user_friends.
2) Friend list now only returns friends who also use your app: The list of friends returned via the /me/friends endpoint is now limited to the list of friends that have authorized your app.
https://developers.facebook.com/docs/apps/changelog
Does this mean that my app will only display to users their Friends that are also using my app? Is there no way for a User to see their entire friends list? And if not, how can I prompt the User to invite new friends to use my app?
Thanks.
Yes, that is exactly what it means, and for what you want to do there is no way to get the friends who did not authorize your App. But maybe you want to use the Send Dialog instead: https://developers.facebook.com/docs/sharing/reference/send-dialog
For that, you don't even need to authorize the user and he can choose the receiver on his own.

fetching list of friends using facebook 2.0

is there any way to fetch list of friends using facebook 2.0 API?
I was reading this upgrade from the API and it seems it is quite difficult to fetch the friends now,
but I have seen 2 permissions
read_friendlist
user_friends
Is their any way to fetch list of friends? and what about the widgets that get friends from facebook, will they go down?
In v2.0 of the Graph API /me/friends returns the user's friends who also use the app. You need to be granted the user_friends permission in order to get even app-using friends.
There is no way in v2.0 to get the full user's friends.
However, you may use the https://developers.facebook.com/docs/graph-api/reference/v2.0/user/invitable_friends API or the https://developers.facebook.com/docs/graph-api/reference/v2.0/user/taggable_friends APIs to get all the user's friends with tokens than can be used for tagging and inviting.
the read_friendlist perm doesn't get you a list of the user's friends, it gets you the list of a user's friendlists which may be used to build a custom privacy selector when publishing stories to Facebook.
As of 4/30/2014, you can only retrieve the friends who also use the app.
There are, however, specific methods for apps in the 'Game' category for inviting friends.
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/invitable_friends/

Can you lookup friends of friends with the Facebook graph API?

My app needs to generate a list of friends for the logged in user, as well as the friends of the friends. The logged in user has authorized the app. So I have no trouble getting their friends. When I make the /friends/ call to the API using one of the friends' IDs, I get this error message:
Can't lookup all friends of [FB ID]. Can only lookup for the logged in user or the logged in user's friends that are users of your app.
I knew that the public visibility of one's friends is a configurable setting for each individual user, but if I understand this message correctly it means that you simply cannot do what I'm trying... ever.
Question #1: Is this true? Is there simply no way to lookup someone's friends' friends?
Question #2: If it's not possible, how do sites like Glassdoor.com manage this exact functionality?
You cannot get the friends of friends of the person who is using the app.
Glassdoor.com sends invitations to the user's friends and when someone accepts, they simply get his friends since he becomes a user of their app.