I'm using the Graph API and the Facebook SDK for PHP with the help of this link: https://developers.facebook.com/docs/php/howto/profilewithgraphapi/4.0.0. This is the code:
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
if($session) {
try {
$user_profile = (new FacebookRequest(
$session, 'GET', '/me'
))->execute()->getGraphObject(GraphUser::className());
echo "Name: " . $user_profile->getName();
} catch(FacebookRequestException $e) {
echo "Exception occured, code: " . $e->getCode();
echo " with message: " . $e->getMessage();
}
}
I'm at the point where I'm able to get a user's name by using user_profile->getName();
, I can also get his/her first name, last name, middle name, etc., according to the API calls here: https://developers.facebook.com/docs/php/GraphObject/#user-instance-methods. I know it is possible to get a user's email address and gender, but in the previous link I didn't find any API calls to be able to get this information.
For Facebook SDK for PHP, what are the API calls to get a user's email address and gender?
Thank you very much.