[英]Problems fetching 'email' from Facebook using javascript sdk api v2.4
I'm using the code that is on the FB Login documentation for Javascript. 我正在使用Java的FB登录文档中的代码。 But it doesn't fetch user's email adresss. 但这不会获取用户的电子邮件地址。 It was working with older versions...but it doesnt with the version of my app (v2.4). 它正在使用旧版本...但不适用于我的应用版本(v2.4)。 I'm also using the facebook login button. 我也在使用Facebook登录按钮。
Here's what I've got: 这是我得到的:
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId: '1650558335190396',
cookie: true,
xfbml: true,
version: 'v2.4'
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/es_LA/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name + response.id);
document.getElementById('status').innerHTML =
'Thanks for logging in, <br>' + response.name + '<br>' + response.id + '<br> <img src="http://graph.facebook.com/' + response.id + '/picture" /></br>' + response.email;
});
}
And this is the button part: 这是按钮部分:
<fb:login-button scope="email,user_birthday,user_about_me" autologoutlink="true" onlogin="checkLoginState();">
</fb:login-button>
FB.api('/me?fields=name,email', function(response) {...
在变更日志中搜索“声明性字段”: https : //developers.facebook.com/docs/apps/changelog#v2_4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.