4

phonegap facebook plugin と facebook javascript api を使用しています。ここに私のコードがあります

FB.init({
    appId: "xxxxxxxxxxxxxxx",
    status: true,
    oauth :true,
    nativeInterface: CDV.FB,
    //channelURL : 'www', // Channel File
    cookie: true, 
    //useCachedDialogs: false, 
    xfbml: true
});

FB.login(function(response) {
    if (response.authResponse) {
        alert(response.authResponse.userID); // literally shows three dots
        FB.api('/me', function(me){
            if (me.id) {
                alert(me.id);  // this works
            }
        });
    }
}, { scope: "email" });

authResponse から accessToken を取得できます....長い文字列です。しかし、userID フィールドは文字どおり "..." です。フェッチする別のグラフ API 呼び出しを使用してサーバーへの余分な往復を行うことで、ユーザーの ID を取得できます/meが、それは無駄に思えます。

4

2 に答える 2

6

[OPの利益のために]表示を開始したときにサーバーに追加の呼び出しを行うことにより、クライアントでユーザーIDを取得できます。正しいコードは次のとおりです。

    FB.api('/me', function(me){
        if (me.id) {
            var facebook_userid = me.id;
            alert(facebook_userid);
        }
    });

"..."これは、userID フィールドがログイン応答オブジェクトにある理由を説明していません。しかし、これは回避策です。

于 2012-05-23T18:31:51.607 に答える
1

これはプラグインの「機能」と思われるため、 github ( https://github.com/davejohnson/phonegap-plugin-facebook-connect/issues/151 )にバグを投稿しました。問題が facebook IOS sdk (FB からこれらのデータを返さない) にあるのか、プラグイン (これらのデータを JS レベルで返さない) にあるのかは不明です。

于 2012-06-08T13:51:33.813 に答える