Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Mutual Friends via Facebook's Graph API

Is there anyway to get a list of mutual friends using Facebook's Graph API?

I've been playing around with this tool and haven't yet figured out a way. However, I saw Simon's demo on Facebook's site, and it sounded like he was able to get the mutual likes of friend of his (it was too blurry to see how he did it so) so I feel like I ought to be able to, but I can't find any documentation besides some php scripts.

like image 303
Ceasar Bautista Avatar asked Jun 21 '11 20:06

Ceasar Bautista


People also ask

What data can I get from Facebook Graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

How do mutual friends show up on Facebook?

@Anwar: If either of the two people have their Friends visible to you then you will see them in Mutual Friends. Only if both of them have their Friends hidden then you won't see them.


3 Answers

The Mutual Friends API was deprecated on April 4, 2018, and the endpoints below started returning empty data sets. The endpoints are now fully deprecated and will return an error. https://developers.facebook.com/docs/graph-api/changelog/version3.1#mutual-friends-api

You can use this one to get mutuals friends from the graph

https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fmutualfriends%2F1207059

like image 164
khammami Avatar answered Sep 28 '22 03:09

khammami


Goto the API Documentation page here:

http://developers.facebook.com/docs/reference/api/

Mid-way down the page you will see:

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

You'll need to replace the /me/ with a valid ID of the person you are looking for and you;ll need to get the access_token as well.

Hope this starts you in the right direction..

EDIT: There is also this which may be easier:

http://developers.facebook.com/docs/reference/rest/friends.getMutualFriends/

Legacy REST method

like image 36
CSSHell Avatar answered Sep 28 '22 04:09

CSSHell


I would do this as a FQL query and test it with their FQL tester. This might not be 100% what you are looking for, but it should be enough to get you started:

   SELECT uid1, uid2 FROM friend 
   WHERE uid1 IN 
   (SELECT uid2 FROM friend WHERE uid1=me())
   AND uid2 IN 
   (SELECT uid2 FROM friend WHERE uid1=me())

You could then look up these id's up against the user table.

like image 22
bkaid Avatar answered Sep 28 '22 03:09

bkaid