-2

https://www.facebook.com/profile.php?id=100010558444183 I want to get this profile id when user login with Facebook.

I tried with this but it gives something else.

try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get('/me',$access_token);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}



$user = $response->getGraphUser();

$id =  $user['id']; ```


andyrandy
  • 72,880
  • 8
  • 113
  • 130

1 Answers1

0

You cannot get the "real" id anymore, only an App Scoped ID that is unique and can still be used for identifying returning users. If you want to get a link to the user profile, use the link field: https://developers.facebook.com/docs/graph-api/reference/v3.2/user

For example:

$response = $fb->get('/me?fields=name,link', $access_token);

More details: https://github.com/facebook/php-graph-sdk/blob/5.x/docs/examples/retrieve_user_profile.md

andyrandy
  • 72,880
  • 8
  • 113
  • 130