Javascript 使用v2.8中的SDK java脚本从facebook connect获取用户电子邮件
我无法检索通过facebook登录按钮连接的人的facebook电子邮件地址。我在2.8版本中使用JDK java脚本Javascript 使用v2.8中的SDK java脚本从facebook connect获取用户电子邮件,javascript,facebook-graph-api,facebook-javascript-sdk,Javascript,Facebook Graph Api,Facebook Javascript Sdk,我无法检索通过facebook登录按钮连接的人的facebook电子邮件地址。我在2.8版本中使用JDK java脚本 <fb:login-button scope="public_profile,email" onlogin="checkLoginState();" auto_logout_link="true"></fb:login-button> <script> window.fbAsyncInit = function() {
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();" auto_logout_link="true"></fb:login-button>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<appId>',
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
};
(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/en_FR/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function checkLoginState() {
FB.getLoginStatus(function(response) {
//console.log('Check login state');
//console.log(response);
statusChangeCallback(response);
});
}
function statusChangeCallback(response) {
if (response.status === 'connected') {
console.log('Connected');
testAPI();
} else if (response.status === 'not_authorized') {
console.log('Please log into this app');
} else {
console.log('Please log into Facebook.');
}
}
function testAPI() {
FB.login(function(response) {
if (response.authResponse) {
var access_token = response.authResponse.accessToken;
FB.api(
'/me',
{fields: 'id,email,cover,name,first_name,last_name,age_range,link,gender,locale,picture,timezone,updated_time,verified'},
function (response) {
console.log('response');
console.log(response);
}
);
} else {
console.log('User cancelled login or did not fully authorize.');
}
},{scope:'email'});
}
function testLogout() {
FB.logout(function(response) {
console.log(response);
});
}
</script>
除了电子邮件,我有所有的信息。你能帮我吗 变化:
FB.api(
'/me',
{fields: 'id,email,cover,name,first_name,last_name,age_range,link,gender,locale,picture,timezone,updated_time,verified'},
function (response) {
console.log('response');
console.log(response);
}
);
致:
用户是否实际授予了电子邮件权限?电子邮件地址是否经过验证?如果未验证,则不会返回。是,在我的对象响应中验证电子邮件已验证:true,并且我在连接期间接受了所有权限。该字段表示配置文件本身是否已验证,与电子邮件无关。配置文件和电子邮件是否不同?如何检查电子邮件是否经过验证?是的,经过验证的个人资料意味着通过短信或信用卡进行验证。您无法明确检查电子邮件是否经过验证,没有额外的字段。在Graph API Explorer中尝试该请求,如果它在那里返回电子邮件,则说明您的代码有问题。
FB.api(
'/me?fields=id,email,cover,name,first_name,last_name,age_range,link,gender,locale,picture,timezone,updated_time,verified',
function (response) {
console.log('response');
console.log(response);
}
);