0

After login with FB JavaScript API, how can I get the profile_id of that user? ('/me'), please help...I used many hours on google and facebook official dev site still no luck on this. How come this kind of simple user profile id also didn't provide in API documentation...is me noob or facebook?.

sesssion_start();

require_once 'autoload.php';
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
use Facebook\FacebookJavaScriptLoginHelper;

FacebookSession::setDefaultApplication( 'APP_ID','APP_SECRET' );
$helper = new FacebookJavaScriptLoginHelper();
$session = new FacebookSession($_POST['access_token']);
$request = new FacebookRequest(
  $session,
  'GET',
  '/me'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
$profile_id = $graphObject->getProperty('profile-id'); // HOW TO GET PROFILE ID??

P.S: I want profile id not user id...

Wei Keat
  • 676
  • 2
  • 9
  • 12
  • Have you tried looking at this? https://developers.facebook.com/docs/php/howto/profilewithgraphapi You should be able to retrieve any pertinent info from there. – Dykotomee Mar 09 '16 at 02:14
  • Tried but I just want profile_id not profile information... – Wei Keat Mar 09 '16 at 03:04
  • Are you sure you're even able to anymore? Check out this answer: http://stackoverflow.com/a/23959831/1299470 – Dykotomee Mar 09 '16 at 03:52

1 Answers1

0

I think You have to get user_id

A user represents a person on Facebook. The /{user-id} node returns a single user.

Here is the reference of Graph Api .. Check it in detail according to your requirement

https://developers.facebook.com/docs/graph-api/reference/user

For profile-id check that link of Graph Api

Reference: Profile /{profile-id}

A profile can be a:

  • User
  • Page
  • Group
  • Event
  • Application

The profile object is used within the Graph API to refer to the generic type that includes all of these other objects.

The individual reference docs for each profile type should be used instead.

Fields

When something has a profile, Graph API returns the fields for that object.

https://developers.facebook.com/docs/graph-api/reference/v2.5/profile/

Muhammad Fahad
  • 1,352
  • 15
  • 15