Javascript facebook登录脚本停止工作
我不知道我的脚本发生了什么,它工作得很好,然后它突然不返回电子邮件(返回未定义),但firstname、lastname和username工作得很好 这是密码Javascript facebook登录脚本停止工作,javascript,facebook,Javascript,Facebook,我不知道我的脚本发生了什么,它工作得很好,然后它突然不返回电子邮件(返回未定义),但firstname、lastname和username工作得很好 这是密码 <script type="text/javascript"> // initialize the library with the API key FB.init({ appId: 'XXXXXXXXXX',status: true, cookie: true, xfbml: true
<script type="text/javascript">
// initialize the library with the API key
FB.init({ appId: 'XXXXXXXXXX',status: true, cookie: true, xfbml: true, oauth: true });
function login() {
FB.login(function (response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function (response) {
console.log('Good to see you, ' + response.name + '.email :' + response.email);
console.log('Good to see you, ' + ",gender:" + response.gender + "another : " + response.first_name);
console.log('Good to see you, ' + response.username + '.last_name :' + response.last_name);
// console.log('Good to see you, ' + response);
}, { scope: 'email' });
} else {
console.log('User cancelled login or did not fully authorize.');
}
});
}
</script>
//使用API密钥初始化库
init({appId:'xxxxxxxxx',状态:true,cookie:true,xfbml:true,oauth:true});
函数登录(){
FB.登录(功能(响应){
if(response.authResponse){
log('欢迎!获取您的信息…);
FB.api('/me',函数(响应){
log(“很高兴见到你,”+response.name+”.email:“+response.email”);
log('很高兴见到你,'+',性别:“+response.gender+”另一个:“+response.first_name”);
log('很高兴见到你,'+response.username+'.last_name:'+response.last_name');
//log(“很高兴见到你,”+响应);
},{范围:'电子邮件'});
}否则{
log('用户取消登录或未完全授权');
}
});
}
但是我没有更改任何内容,有什么问题吗?要获取电子邮件,需要将
{scope:'email'}
传递给,而不是作为FB.api
的参数
FB.login(function (response) {
...
}, { scope: 'email' });
我忘了提到,当我登录facebook时,它只要求获得基本信息访问权限,根本没有提到电子邮件。