0

我添加到 phonegap 应用程序 Facebook Connect,它工作正常并生成访问令牌,但是当我尝试获取用户 ID 时,我的函数的值为 “Undenified”

 FB.init({
        appId: "************",
        nativeInterface:CDV.FB,
        xfbml: true,
        useCachedDialogs: false,
        status: true,
        cookie: true,
        oauth: true
    });
    //alert("Init Done");
    FB.getLoginStatus(function (response) {
        if (response.authResponse) {               
            if (response.status == 'connected') {                  
                Token = response.authResponse.accessToken;// This one is Good!                   
                userid = response.authResponse.userID;// This one is Bad                  

            }
4

2 回答 2

1

我使用以下,它工作正常:

FB.api('/me', {}, function (response) {
    fbuserid = response.userid;
});

这为您提供了用户数据。您还可以传递范围只是为了获得您想要的内容,例如电子邮件、用户 ID 等...

于 2012-10-20T04:59:55.150 回答
0

遍历键以查看存储的内容

for (var key in response.authResponse) {
    console.log(key);
    console.log(response.authResponse[key]);
}
于 2012-10-20T05:12:21.080 回答