从 Facebook PHP SDK 获取用户的电子邮件 ID
我尝试使用以下代码
第一的
$user_profile = $facebook->api('/me'); // or $facebook->api('/me?fields=email')
print_r($user_profile);
第二
$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);
第三
$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);
这些都不会获得登录用户的电子邮件 ID。如何找回它?