1

javascript sdk を使用して接続ユーザーの Facebook ウォールに投稿しようとしています。これが私のコードです。

     var connecter=false;
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'xxxxxxx', // App ID
      oauth      : true,
      channelUrl : '//www.streamazing.net/js/channel.html', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

    FB.Event.subscribe('auth.login', function (response) {
               window.location.reload();
            });

    FB.Event.subscribe('auth.logout', function (response) {
               window.location.reload();
            });



    FB.getLoginStatus(function(response) {
            if (response.status === 'connected') {
                connecter=true;
                FB.api('/me', function(user) {
                var user2=user;
                console.log(user2.name);

                });

            }
        else connecter=false;
        });





    var body = 'This is a test';
                FB.api('/me/feed', 'post', { message: body }, function(response) {
                    if (!response || response.error) {
                        console.log(response.error);
                    } else {
                        alert('Post ID: ' + response.id);
                    }
                });
};

コンソールログは次のとおりです。

code: 2500
message: "An active access token must be used to query information about the current user."
type: "OAuthException"

私はこのコードで許可を求めています:

<fb:login-button autologoutlink='true'  scope='email,user_birthday,status_update,publish_stream'></fb:login-button>

Facebook がアクセス トークンを要求する理由がわかりません。誰か助けてもらえますか? どうもありがとうございました。

4

3 に答える 3

0

Javascript SDK を使用してユーザーのフィードに投稿する場合は、代わりに FB.ui を使用してください。 http://developers.facebook.com/docs/reference/javascript/FB.ui/

それ以外の場合、publish_stream 拡張アクセス許可に必要なアクセス トークンは、response.authResponse.accessToken の下の FB.getLoginStatus メソッド内に格納されます。 http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

于 2012-04-20T20:43:01.270 に答える
0

すべての FB URL に access_token= でリクエストを行う必要があります。

于 2012-08-17T21:18:42.993 に答える
0

FB.init() を呼び出します。すべての fb sdk 関数が宣言された後。

于 2013-08-19T13:00:54.507 に答える