Facebook身份验证登录不会刷新页面

Facebook authentication login does not refresh page

本文关键字:刷新 身份验证 登录 Facebook      更新时间:2023-09-26

我使用PHP SDK 3.x.x和Javascript SDK的组合来登录Facebook身份验证。当我们单击登录按钮时,会出现窗口,填写凭据并提交后不会刷新页面。FB.Event.subscribe('auth.login')似乎没有触发。问题出在哪里?

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);
}());

据我所知,这个登录过程是使用AJAX处理的,这就是页面部分刷新的原因。我不知道你面临的问题是什么。在我的解决方案中,我在页面的第一部分使用了这个登录过程,并基于fb$user和$user_profile定义了变量和会话。后来使用这些变量来更新页面的其他部分。由于事件没有被触发,您应该检查js并使用fb示例来了解它们的sdk是如何工作的希望这能对你有所帮助。