How to get friends in order of the number of common friends?

I am developing a Facebook application. I want to know how I can get friends in order of the number of mutual friends. Is this possible with FQL or any other method?

+4
source share
4 answers

Update

I can’t find a way to do this in one request using the graphical API, but this can be done in Ruby by getting a list of friends, then sending the request to each friend using a User context , for example this example

Original answer

Here is the FQL query to be used , which only works for api versions <v2.1

SELECT uid, mutual_friend_count from user where uid in (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY mutual_friend_count desc 

you can try it in explorer

https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20uid%2C%20mutual_friend_count%2C%20friend_count%20from%20user%20where%20uid%20in%20%28SELECT%20uid2% 20FROM% 20friend% 20WHERE% 20uid1% 3Dme% 28% 29% 29% 20ORDER% 20BY% 20mutual_friend_count% 20desc

+5
source

Theoretically, you can get a list of user's friends using:

 $friendsOfFriend = $facebook->api('/'.$yourFriendsFacebookId.'/friends'); 

You can then check each result to see if they are also your friend.

 $isMyFriend = $facebook->api('/me/friends/'.$someonesFacebookId); 

... and track the score.

However, my test has not yet returned the result. I tried to get some friends of my friends on facebook, but it returns an exception: Can't lookup all friends of {friend's_facebook_ID}. Can only lookup for the logged in user {my_facebook_ID}, or friends of the logged in user with the appropriate permission Can't lookup all friends of {friend's_facebook_ID}. Can only lookup for the logged in user {my_facebook_ID}, or friends of the logged in user with the appropriate permission . So there might be a rights issue here.

+2
source

I don’t think that common friends are accessible through FQL, so you have to do it hard: call the api schedule in a loop for each friend and get the number of common friends. The api graph method is: / me / friendsfriends / yourFriendsId, and you can make 20 batch requests at a time to speed this up. If you can find a way to do this using FQL, this will be your fastest route.

+1
source

This is only a partial answer, since they are not all in one place, but have not yet found a way to get them on one page, but this is a launch that can be run in a loop programmatically through a list of friends ...

 https://www.facebook.com/browse/mutual_friends/?uid=xxxxxxxxxxxx 

because if you do not give uid, it returns an error ... I was just trying to get a list of all my friends on one page, but not a cube. ridonculous.

0
source

All Articles