2

So I've been trying for this for a couple of days, trying to figure out how to use Facebook's Graph API v2.2 to get mutual friends between two users. I understand that I can only get the mutual friends between two users that are using the FB App and that's cool.

The app has the following approved items:

  • email
  • public_profile
  • user_birthday
  • user_friends
  • user_hometown
  • user_location
  • user_relationships
  • user_website

My scenario is this:

  • A user (user A) register to the FB App
  • Another user (user B) registers
  • User A looks at the user B's profile
  • The profile should display the mutual friends between the two users

I've tried to play around in the Graph API Explorer

/v2.2/app_scoped_user_id?fields=context.fields%28mutual_friends%29
and
/v2.2/user_id?fields=context.fields%28mutual_friends%29.
These just returns an ID field with the ID I provided and nothing else.

I'm all out ideas, and the docs isn't helping much either. Can someone explain how to do it? I will be using it in an Angular app but as long as I can get the URL to fetch the correct thing I can translate it into Javascript.

Carl0s1z
  • 4,683
  • 7
  • 32
  • 47
jwanglof
  • 548
  • 1
  • 5
  • 20
  • Mutual friends will just return the mutual friends that are also using the app. Are any of user A and Bs friends using the app? – WizKid Nov 22 '14 at 17:53
  • @WizKid: Yes, user A and user B have common friends that have authorized themselves with the app, that's the thing that's strange. – jwanglof Nov 23 '14 at 20:05
  • And A and B and the mutual friends have granted user_friends to the app? – WizKid Nov 23 '14 at 20:15
  • @WizKid: I'm pretty sure they have. Can I check which user's that are using the app and which items they have approved? – jwanglof Nov 23 '14 at 20:21
  • This works only if User A and User B are friends. Did you figure out any solution? – Manas Paldhe Feb 27 '15 at 06:39
  • @ManasPaldhe: Nope, I stopped trying after a while because we started working on another feature on the site. Guess I'm gonna try it again in a while. – jwanglof Feb 28 '15 at 12:45
  • 1
    @jwanglof: I posted a very similar question: http://stackoverflow.com/questions/28759042/finding-mutual-friends-on-facebook. It looks like this is a bug in the facebook API (read the comments on that question) – Manas Paldhe Feb 28 '15 at 23:16

1 Answers1

1

For v2.3 - https://developers.facebook.com/docs/graph-api/reference/v2.3/user.context/mutual_friends

Between friends make sure the user_id in the query is the Facebook id of the other friend not the current user whose access token you are using.

GET /v2.3/{other_user.user-id}?fields=context.fields%28mutual_friends%29

For querying mutual friends between two non-friends you need to add a server appsecret_proof parameter plus the user access token.

Carl0s1z
  • 4,683
  • 7
  • 32
  • 47
  • That new edge worked. Thank you very much for pointing it out! =) – jwanglof Apr 23 '15 at 13:54
  • Thought I'd just add this, it seems like mutual_friends have a limit on 10 friends (tried to raise the limit but couldn't get above 10 friends). Found all_mutual_friends (https://developers.facebook.com/docs/graph-api/reference/user-context/all_mutual_friends/) instead which doesn't seem to have a limit =) – jwanglof Apr 23 '15 at 19:39