2011-07-17 39 views

回答

1

我認爲,這應該是你的函數:

FB.ui({ 
    method: 'oauth', 
    display: 'popup', 
    scope: 'email', 
    response_type: 'token', 
    redirect_uri: 'WHEREYOUWANTTOPROCESSTOKEN', 
    client_id: 'YOURAPPID', 
}); 

請注意,只有pagepopup是有效類型display

+0

(-1)顯示必須是以下之一: 1-彈出窗口2-對話框3- iframe 4-觸摸5-異步5-隱藏6-無 – Hiyasat

+0

這些參數可以與其他對話框一起使用,但我相信驗證對話框專門只允許頁面和彈出窗口來保證這個重要階段認證過程。觸摸在這裏也可能有效,但對於移動以外的任何其他應用可能都沒有用處。 –

+0

這是來自服務器的響應,如果你使用頁面顯示:) – Hiyasat

1

這個例子可能會有幫助:http://fbrell.com/auth/login-and-logout

<button id="fb-auth">Login</button> 

<script> 
function updateButton(response) { 
    console.log('Updating Button', response); 
    var button = document.getElementById('fb-auth'); 

    if (response.session) { 
    button.innerHTML = 'Logout'; 
    button.onclick = function() { 
     FB.logout(function(response) { 
     console.log('FB.logout callback', response); 
     }); 
    }; 
    } else { 
    button.innerHTML = 'Login'; 
    button.onclick = function() { 
     FB.login(function(response) { 
     console.log('FB.login callback', response); 
     if (response.session) { 
      console.log('User is logged in'); 
     } else { 
      console.log('User is logged out'); 
     } 
     }); 
    }; 
    } 
} 

// run it once with the current status and also whenever the status changes 
FB.getLoginStatus(updateButton); 
FB.Event.subscribe('auth.statusChange', updateButton); 
</script>