我在使用facebook api从用户登录后从Facebook检索用户电子邮件地址时遇到问题,我在stackoverflow上查看过很多与此相关的帖子,但仍无法解决我的问题
查看链接
https://stackoverflow.com/questions/17828849/i-cant-get-user-email-address-on-facebook
I cant get user email address on facebook
这是我的代码
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => $client_id,
'secret' => $client_secret,
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Get the user profile data you have permission to view
$user_profile = $facebook->api('/me');
echo "<pre>";
print_r($user_profile);
echo "</pre>";
} catch (FacebookApiException $e) {
$user = null;
}
} else {
die('<script>top.location.href="'.$facebook->getLoginUrl().'";</script>');
}
$loginUrl = $facebook->getLoginUrl(array(
'scope' => 'email, read_stream, publish_stream, user_birthday, user_location, user_work_history, user_hometown, user_photos'
));
echo $user_profile['email'];
任何帮助将不胜感激。感谢
除了电子邮件地址之外,还显示我需要的其他信息