伙计们,我有一个自定义按钮,它会触发FB.login()事件,但是我无法获取电子邮件信息,facebook不会要求用户访问电子邮件并返回name,id字段
FB.login(function(response) {
console.log(response)
if (response.authResponse) {
FB.api('/me?fields=id,name,email', function(data) {
console.log(data)
if ((typeof data.email === 'undefined') ||(data.email == '') || (data.email == null)) {
M.toast({html: "You dont't give an email access, we are can't register you without email. Sorry :("});
return false;
}
window.flags.signin = {
status: true,
name_surname: data.name,
email: data.email,
login_type: 'facebook',
id: data.id
}
// back-end request func
window.flags.submitFunc('veriler='+JSON.stringify(window.flags.signin));
}, { scope: 'id,name,email'});
}
else {
M.toast({html: 'User cancelled login or did not fully authorize.'});
}
});
修复它,我改变这条线
{ scope: 'id,name,email'}
to
{ scope: 'email'}
开始询问电子邮件访问权限