Facebook PHP SDK how to get user email from Facebook JavaScript SDK 2014

facebook, facebook-graph-api, javascript, php, sdk

Solution

`GraphUser` inherits from `GraphObject` so you should be able to use the generic method to grab a field:

$user_profile->getProperty("email");

Problem

I am using both Facebook PHP(4.0) and JS(2.0) SDK together. I can grab the user profile data with PHP but not the user's email. The user's email is available with the Javascript SDK, but I need it in PHP. I was using: ``` $user_profile = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className()); ``` This works but the class GraphUser does not have a function to grab the user's email in 4.0. Any ideas how I can grab user's email with Facebook PHP SDK version 4.0 ?

Original source