How Do I Get The List Of Mutual Friends On Facebook Using Their Api?
Solution 1:
This will give a list of mutual friends:
$mutual_friends = $facebook->api('/me/mutualfriends/friendid');
Solution 2:
Ok... This one gave me a real hard time. I managed to do this using the Facebook JS SDK. Here's the snippet just in case anyone else wants to do this:
FB.api(
{
method: 'fql.query',
query: 'SELECT id FROM profile WHERE id IN (SELECT uid2 FROM friend WHERE uid1=me())'
},
function(response) {
$.each(response, function(json) {
console.info(response[json].id);
FB.api(
{
method: 'friends.getMutualFriends',
target_uid: 'INSERT ANOTHER FRIEND ID HERE'
},
function(response) {
console.info(response);
}
);
returnfalse;
});
}
);
Solution 3:
This is working 2016/ JAN
The result is a Json with your common friends. Working in Graph v2.4 and v2.5 fine.
PS: if you searching for ALL_mutual_friend is friends without the same app instaled Mutual_friends -> booth users you from token session and another one in query have the app autorized.
new field in facebook user.context https://developers.facebook.com/docs/graph-api/reference/user-context/
(Use Graph Explorer to Test )
Solution 4:
I had same problem. Though it is very late for answering question, it will help somebody. That's why answering this question.
Legend
given answer is giving only mutual friends for friend. I have given solution which gives mutual friends of user(friend or friend of friend).
You asked mutual friends of myself and another user
(not only friend) and in PHP.
So below is solution:
$source_id=current user
$target_id=friend or friend of friend
$query="SELECT uid, name, work FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = $source_id and uid2 IN (SELECT uid2 FROM friend WHERE uid1 = $target_id) ) ORDER BY name";
$freinds_list=$this->facebook->api(array('method'=>'fql.query',
'query'=>$query));
Solution 5:
Well it's actually friends.getMutualFriends().
Have a play here.
Post a Comment for "How Do I Get The List Of Mutual Friends On Facebook Using Their Api?"