2012-03-08 8 views
0

FBの統合について私の頭を上げるのに本当に助かります。FB.initから真のパラメータであるクッキーを削除すると、Facebookのウェブサイトアプリが無限ループになります

私はjavascriptのSDKを使用するために、標準FB.initを使用して、いくつかの基本的なAPI呼び出しを行うにはPHP SDKを使用しています:私はテストのものだったとクッキーコメントアウト

FB.init({ 
    appId  : '265236093556723', // App ID 
    status  : true, // check login status 
// cookie  : true, // enable cookies to allow the server to access the session. WHY IS THERE AN INFINITE LOOP WHEN THIS IS REMOVED?!?!?!?!?! 
    xfbml  : true, // parse XFBML 
    oauth  : true, 
    channelUrl : 'http://www.loveweber.co.uk/dev/fbchannel.php' // Channel File 

}); 

:真の行を。これはサイトがページを再現してループする原因となりました。私はどこでもPHPがJavascriptによって設定されたこのクッキーを使用することを読んでいます...それはAPIへのPHP呼び出しと何か関係ありますか?

それともとは何か:

 FB.Event.subscribe('auth.login', function(response) { 
     window.location.reload(); // When user logs in, the page refreshes... 
     }); 
    FB.Event.subscribe('auth.logout', function(response) { 
      window.location.reload(); 
     }); 

ページのrealodingまたはアウトユーザーがログイン?

ありがとうございました。

答えて

1
FB.Event.subscribe('auth.login', function(response) { 
    window.location.reload(); // When user logs in, the page refreshes... 
}); 
FB.Event.subscribe('auth.logout', function(response) { 
     window.location.reload(); 
}); 

どちらのイベントサブスクリプションでも応答変数をチェックしていないことに気付きました。あなたは盲目的にreload()を行う前に、あなたがそれがあなたが思っているものであることを確認するべきです。 Facebookがあなたにレスポンスオブジェクトを送信する理由は、常にあなたが思うものではないからです。

レスポンスオブジェクトは次のようになります。ですから、auth.loginに加入するときのResponse.Statusが「接続」されていることを確認し

 { 
     status: "xxx",   /* Current status of the session */ 
     authResponse: {   /* Information about the current session */ 
      userID: ""   /* String representing the current user's ID */ 
      signedRequest: "", /* String with the current signedRequest */ 
      expiresIn: "",  /* UNIX time when the session expires */ 
      accessToken: "", /* Access token of the user */ 
     } 
    } 

。 auth.logoutに登録すると「接続されていません」。

関連する問題