我正在使用 javascript + PHP
<!DOCTYPE html>
<html xmlns:fb='http://www.facebook.com/2008/fbml'>
<body>
<fb:login-button scope='email,user_photos'></fb:login-button>
<div id='fb-root' ></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '478449982166112',
cookie: true,
xfbml: true,
oauth: true
});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
FB.Event.subscribe('auth.logout', function(response) {
window.location.reload();
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>.
</body>
</html>
如您所见,我正在请求电子邮件权限。
然后我从 PHP 调用 /me:
$user = $facebook->getUser();
if ($user) {
try {
// if user is logged on to facebook, the account details will be saved in $me variable
$me = $facebook->api('/me');
} catch (FacebookApiException $e) {
// if user is not logged on to facebook, set $user to null .
$user = null;
}
}
但它不包含电子邮件字段。