Reputation: 753
I am making the following Facebook Graph API call in PHP
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id'); // To Get Facebook ID
$fbuname = $graphObject->getProperty('username'); // To Get Facebook Username
$fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
$femail = $graphObject->getProperty('email'); // To Get Facebook email ID
The API call is working. If I am logged in, then this API call returns my information and I can print my full name and my numeric facebook id. But the Graph API documentation shows that there are a lot more fields to be read, like email, gender, hometown, etc.
How can I get those fields.
I ran
var_dump($graphObject);
this was the result
object(Facebook\GraphObject)#5 (1) { ["backingData":protected]=> array(2) { ["name"]=> string(27) "Shoeb Muhammad Moniruzzaman" ["id"]=> string(17) "10206785004401959" } }
Upvotes: 0
Views: 938
Reputation: 3935
For the other fields, you have to ask them in the request, eg.
$request = new FacebookRequest( $session, 'GET', '/me?fields=name,about' );
$request = new FacebookRequest( $session, 'GET', '/me?fields=name,birthday' );
and obviously, you have to have the permissions. Graph API Explorer is very useful for these cases.
Upvotes: 2