Get the Email ID of user from Facebook PHP SDK
I tried with below codes
First
$user_profile = $facebook->api('/me'); // or $facebook->api('/me?fields=email')
print_r($user_profile);
Second
$user = $facebook->getUser();
$url = "https://api.facebook.com/method/fql.query";
$url .= "?access_token=" . $access_token;
$url .= "&query=SELECT email FROM user WHERE uid={$user}";
$userData = simplexml_load_file($url);
$userEmail = $userData->user->email;
print_r($userEmail);
Third
$user = $facebook->getUser();
$fql = "select name, hometown_location, sex, pic_square, email from user where uid='$user'";
$param = array(
'method' => 'fql.query',
'query' => $fql,
'access_token' =>$access_token ,
'callback' => ''
);
$fqlResult2 = $facebook->api($param);
print_r($fqlResult2);
None of these will get the email id of login user . How to retrieve it ?