在Facebook登录官方示例中使用scope
我知道一些Facebook用户没有电子邮件地址。他们可以使用电话号码。无论如何,在这个正式的JS示例中,我不知道应该在代码的哪一部分添加在Facebook登录官方示例中使用scope,facebook,facebook-javascript-sdk,facebook-login,Facebook,Facebook Javascript Sdk,Facebook Login,我知道一些Facebook用户没有电子邮件地址。他们可以使用电话号码。无论如何,在这个正式的JS示例中,我不知道应该在代码的哪一部分添加{scope:'email'} 它就在文档中,只需向下滚动一点 …或具有箭头功能: FB.login((response) => { // handle the response }, {scope: 'email'}); 授权后,您可以通过以下API调用获取电子邮件: FB.api('/me', {fields: 'name,email'}, (
{scope:'email'}
它就在文档中,只需向下滚动一点
…或具有箭头功能:
FB.login((response) => {
// handle the response
}, {scope: 'email'});
授权后,您可以通过以下API调用获取电子邮件:
FB.api('/me', {fields: 'name,email'}, (response) => {
console.log(response.email);
});
我明白了。解决方案是在此处添加
email
param
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me?fields=name,email', function(response) { //<-HERE ?fields=name,email
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + response.id + response.email +'!';
});
函数testAPI(){
log('欢迎!获取您的信息…);
FB.api('/me?fields=name,email',function(response){//您实际上是问在哪里添加范围参数,而不是在api调用中在哪里请求email字段……不过,我也会以更好的方式将其添加到我的答案中。请查看,它是第二个参数。
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me?fields=name,email', function(response) { //<-HERE ?fields=name,email
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + response.id + response.email +'!';
});