context.fields(all_mutual_friend) returns Unsupported get request

160 Views Asked by At

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?

1

There are 1 best solutions below

1
Fredrik On

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();