0
votes

I am new in Facebook API integration. I am able to get user's profile and list of friends who use my Application. But, I want the list of mutual friends between user login in my APP and his/her friend. i am attach code that i used:

   //facebook application configuration
    $fbconfig['appid' ] = "636631533131524";

    $fbconfig['secret'] = "d325de230128984562kba45341e574f0";
    try{
        include_once ('.\facebook-php-sdk-master-master\src\facebook.php');
    }
    catch(Exception $o){
        print_r($o);
    }
    $facebook = new Facebook(array(
      'appId'  => $fbconfig['appid'],
      'secret' => $fbconfig['secret'],
      'cookie' => true,
    ));
    $user       = $facebook->getUser();
    $loginUrl   = $facebook->getLoginUrl(
            array(
                'scope'         => 'email'
            )
        );
    if ($user) {
      try {
        $user_profile = $facebook->api('/me');
        $user_friends = $facebook->api('/me/friends');
        $mutual_friends = $facebook->api('/me/mutualfriends/844865302256121');
        $access_token = $facebook->getAccessToken();
      } catch (FacebookApiException $e) {
        d($e); 
        $user = null;
      }
    }

Please tell me how to do this process?

Thanks

1
Please edit your question and add a code snippet you tried to use. It would help people answering your question greatly! Read more about how to ask a great question. - methode

1 Answers

0
votes
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{user-id}',
  array (
    'fields' => 'context.fields(mutual_friends)',
  )
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

Facebook Developers and Read this Answer too