Using Facebook graph API, I am trying to retrieve number of mutual friends 2 users have. However, I am getting number of friends of one of them instead.
Here is my code:
<?php
$mutual_array = json_decode(file_get_contents("https://graph.facebook.com/".$fb_id."/mutualfriends/".$other_fb_id."?".$access_token), true);
$mutual_friends = $mutual_array['data'];
$mutual_number = count($mutual_friends);
?>
$mutual_number gives the number of facebook friends $other_fb_id user has. And when I try to print_r $mutual_friends it gives all the friends the user has.
Anyone know what’s going on here? Thanks.
This is a facebook api bug. Even though the information is symetrical, to get the number of mutual friends, you have to use the access token of the current user (user a), not of the other user you are checking with.