我正在尝试使用Facebook api获取一些基本信息,但到目前为止我只获得了用户的名字和ID.如在{ name: "Juan Fuentes", id: "123456" }
我需要获得电子信息,如电子邮件,名字,姓氏和生日
这是我的js代码
function facebookLogin() {
FB.login(function(response) {
var token = response.authResponse.accessToken;
var uid = response.authResponse.userID;
if (response.authResponse) {
FB.api('/me', 'get', { access_token: token }, function(response) {
console.log(response);
});
FB.api('/'+uid, 'get', { access_token: token }, function(response) {
console.log(response);
});
}
},
{ scope: 'public_profile' }
);
}
Run Code Online (Sandbox Code Playgroud)
这是激活它的按钮
<a id="fb-login" href="#" onclick="facebookLogin()"></a>
Run Code Online (Sandbox Code Playgroud)