2013-07-03 108 views
0

我嘗試使用Facebook的JS SDK,我倒了一個問題。Facebook JS sdk Oauth onload

我想要的頁面加載後,用戶點擊FB按鈕,然​​後, 如果他已經登錄我改變位置, 如果沒有, 它觸發FB洛彈出

這裏我的代碼「

window.fbAsyncInit = function() { 
    // init the FB JS SDK 
    FB.init({ 
     appId  : '<?php echo $action->appId; ?>', // App ID from the app dashboard 
     status  : true,    // Check Facebook Login status 
     cookie  : true,   // enable cookies to allow the server to access the session 
     xfbml  : true    // Look for social plugins on the page 
    }); 

FB.Event.subscribe('auth.authResponseChange', function(response) { 

     if (response.status === 'connected') { 
      $(location).attr('href','nexPage.php'); 

     } else if (response.status === 'not_authorized') { 
      FB.login(); 
     } else { 
      FB.login(); 
     } 
    }); 

我的問題都與事實facebook的authResponseChange觸發的onload因此,如果用戶已經登錄,只是他被直接發送到下一個頁面在頁面上到達,我不想那! 我希望用戶看到pa首先,點擊,然後登錄/或不進入下一頁 有人知道如何做到這一點嗎?

(並且沒有點擊事件可能導致用戶登錄後,FB重新載入頁面)

回答

0

找到了!

把狀態爲假

FB.init({ 
     appId  : '<?php echo $action->appId; ?>', // App ID from the app dashboard 
     status  : false,    // Check Facebook Login status 
     cookie  : true,   // enable cookies to allow the server to access the session 
     xfbml  : true    // Look for social plugins on the page 
    }); 

對不起,打擾