hiprakhar
hiprakhar

Reputation: 1017

Facebook api how to get userid and name?

I am using facebook php api for fetching data. Please help me on how to authenticate and fetch userid, name, email, gender.(I HAVE asked for email permission).

Here is my code:

require 'facebookcredentials.php';
require 'facebookapi.php';
$facebook = new Facebook(array(
  'appId'  => $app_id,
  'secret' => $secret,
  'cookie' => true,
));

     $facebook->getLoginUrl(array('req_perms' => 
    'email,read_stream,publish_stream,create_event,rsvp_event'));

Please tell me how to first authenticate the user and then get $userid, $name, $gender, $email

Upvotes: 1

Views: 10336

Answers (1)

fingerman
fingerman

Reputation: 2470

You can use the example here: https://github.com/facebook/php-sdk/blob/master/examples/example.php it helps a lot...

anyway, you are looking for these: $me = $facebook->api('/me');

see the whole example though.

Upvotes: 2

Related Questions