2012-01-11 152 views
1

我使用PHP SDK 3.x.x和Javascript SDK的混合登錄到Facebook身份驗證。當我們點擊登錄按鈕時,出現窗口,填寫憑證並提交後不會刷新頁面。 FB.Event.subscribe('auth.login')似乎沒有觸發。問題是什麼?Facebook身份驗證登錄不刷新頁面

window.fbAsyncInit = function() { 
FB.init({ 
    appId : '<?php echo $facebook->getAppId(); ?>', 
    oauth : true, // check login status 
    cookie : true, // enable cookies to allow the server to access the session 
    xfbml : true // parse XFBML 
}); 

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

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


}; 

(function() { 
var e = document.createElement('script'); 
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
e.async = true; 
document.getElementById('fb-root').appendChild(e); 
}()); 
+0

控制檯中是否有錯誤? – sarnold 2012-01-11 02:13:20

+0

nope。 :(我認爲會有一些js錯誤,但沒有。 – Blueboye 2012-01-11 02:51:31

+0

你可以從這裏找到解決這個問題:http://stackoverflow.com/questions/7141762/fb-event-subscribe-and-login-button – 2012-01-13 08:49:03

回答

0

據我所知,這個登錄過程是使用AJAX處理的,這就是頁面被部分刷新的原因。我不知道你面臨的問題是什麼。在我的解決方案中,我在頁面的第一頁使用了此登錄過程,並根據fb $ user和$ user_profile定義變量和會話。稍後使用這些變量來更新頁面的其他部分。 由於事件沒有被觸發,你應該檢查js並使用fb示例來了解它們的sdk如何工作 希望這可能對你有所幫助。