用Facebook登录后获取用户的FID,姓名和电子邮件

时间:2012-05-05 22:15:52

标签: facebook facebook-graph-api facebook-javascript-sdk

我希望在使用Javascript登录后获取用户的FID,电子邮件和姓名,因此我进行了Ajax调用并将其保存到数据库中。

这是目前登录用户的代码:

    if (response.status === 'connected') { // the user is logged in and connected to your application
        var uid = response.authResponse.userID;
        var accessToken = response.authResponse.accessToken;
        // Alert with fid, email and name
        } else { //the user isn't logged in to Facebook or isn't connected to the application
        FB.login(function(response) {
            if (response.authResponse) {
                accessToken = response.authResponse.accessToken;
                // Alert with fid, email and name
                }
            }, {scope: 'email'});
        }

我该怎么做?

1 个答案:

答案 0 :(得分:2)

呼叫

https://graph.facebook.com/me

https://graph.facebook.com/USER_ID

https://graph.facebook.com/fql?q=SELECT uid,name,email FROM user WHERE uid=me()

你需要

email

许可