我有这种方法,我想收到一个人的电子邮件并发送电子邮件=未定义。
首先尝试:
function testAPI() {
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.email + '.');
alert('Good to see you, ' + response.email + '.');
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope:'email'});
我正在搜索,我发现我必须使用{scope:image},如果我把它,不要告诉我警报
答案 0 :(得分:24)
替换此
FB.api('/me', function(response) {
// ...
用这个
FB.api('/me?fields=id,name,email,permissions', function(response) {
console.log(response.name);
console.log(response.email);
// ...
我可以收到用户的电子邮件。
答案 1 :(得分:6)
你的语法错了,这是正确的:
item in Pictures
其中function testAPI() {
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.email + '.');
alert('Good to see you, ' + response.email + '.');
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
},
{scope:'email'}
);
}
位于)中,作为FB.login的第二个参数
答案 2 :(得分:6)
或使用
FB.init('/me', {"fields":"id,name,email,first_name,last_name"}, function(response){
console.log(response.email);
});