FB Graph API: Mutual Friends returns empty array

2019-08-17 00:01发布

问题:

I am having an FB app and I want to find mutual friends between 2 users using my app.

When I use Graph Explorer for my app to find the mutual friends between 2 users connected to my app, it returns the correct results.

However, when I run the same query on my facebook php sdk, I get empty results. This is my code:

$fb_app_id = $this->config->item('facebook_app_id');
$fb_secret = $this->config->item('facebook_secret');
$facebook = new Facebook(array(
                                    'appId'  => "$fb_app_id",
                                    'secret' => "$fb_secret",
                                    ));
$mutual_friends = $facebook->api("/802150300/mutualfriends/626070638");

$mutual_friends is an empty array here. Any ideas why I am getting it empty?

回答1:

I don't think the facebook API allows you to get mutuals friends between any two friends. You can only access how many mutual friends you and another friend have.