Javascript 使用Facebook用户Id(java脚本)获取Facebook好友的电子邮件
需要一些帮助,使用Facebook用户Id获取Facebook好友的电子邮件地址。 这是我的代码:Javascript 使用Facebook用户Id(java脚本)获取Facebook好友的电子邮件,javascript,facebook,email,Javascript,Facebook,Email,需要一些帮助,使用Facebook用户Id获取Facebook好友的电子邮件地址。 这是我的代码: //this is the getLoginStatus - with email permissions FB.getLoginStatus(function(response) { // Check login status on load, and if the user is // already logged in, go directly to the welcome mess
//this is the getLoginStatus - with email permissions
FB.getLoginStatus(function(response) {
// Check login status on load, and if the user is
// already logged in, go directly to the welcome message.
if (response.status == 'connected') {
onLogin(response);
} else {
// Otherwise, show Login dialog first.
FB.login(function(response) {
onLogin(response);
}, {scope: 'user_friends, public_profile, email'});
}
});
//this the code I use to try to fetch the email address
var email="";
FB.api(
"/" + userIds[0],
function (response) {
if (response && !response.error) {
email = response.email;
}
}
);
请注意,我收到了回复(包括名字、身份证、性别等),但不包括电子邮件-即使我的应用程序请求电子邮件访问权限,如果我的facebook用户正在使用我的应用程序,也不包括电子邮件
任何提示都将不胜感激。用户不必接受
电子邮件
许可,即使其被要求。如果您不亲自处理,每个权限都可以拒绝,但仍可以使用该应用。在这种情况下,我使用测试用户(验证所有用户是否接受电子邮件权限)-我仍然没有收到电子邮件…测试用户是否有电子邮件?API路径不应该是/me
而不是/userId
?您只能读取应用程序当前用户的电子邮件地址,不能读取他们的朋友的电子邮件地址。朋友是否已授予你的应用程序阅读其电子邮件的权限并不重要,你只能使用他们自己的用户访问令牌来阅读。谢谢!这似乎是正确的答案。。。