0

I'm trying to get all mutual friends between me and other (not my friend) user.

To do it i use a php server connecting with graph.facebook.com (REST client)

I'm using the AppSecret from dashboard I'm sending valid access_token (with user_friends permission) I'm sending valid appsecret_proof (created with the mentioned in docs method):

$appsecret_proof = hash_hmac('sha256', $access_token, $secret);

If i change appsecret_proof i recieve "Invalid appsecret_proof provided in the API argument" so i think that it is correct and valid.

Always i retrieving the same response:

 "error": {
       "message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
        "type": "GraphMethodException",
        "code": 100,
        "fbtrace_id": "XXXXXXXXXXX"
      }

this is my code:

$appsecret_proof = hash_hmac('sha256', $access_token, $secret);

$url =  '/v2.5/'.$userID.'?fields=context.fields(all_mutual_friends)&appsecret_proof='.$appsecret_proof.'&access_token='.$access_token ;

$config = array('server'=> 'https://graph.facebook.com');
$this->CI->rest->initialize($config);
$result = $this->CI->rest->get($url);

How can i retrieve our mutual friends?

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
Bamboo
  • 1
  • 1
  • I got the same error message, but it only happened when I query between real facebook user vs facebook test user. For real fb user vs fb_user, or test user vs test user, they both are fine. Have you found the solution already? – Samnang Mar 08 '16 at 07:53

1 Answers1

1

According to the documentation it's supposed to be mutual_friends, not all_mutual_friends.

Example code being:

$request = new FacebookRequest(
  $session,
  'GET',
  '/{user-id}',
  array (
    'fields' => 'context.fields(mutual_friends)',
  )
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
Fredrik
  • 764
  • 1
  • 6
  • 22
  • I'm using this for get all friends that the viewer and the target person have in common. This includes the friends who do not use my App. [Documentation](https://developers.facebook.com/docs/graph-api/reference/user-context/all_mutual_friends/ "Documentation") – Bamboo Dec 12 '15 at 12:39