在facebook连接中禁用自动登录

时间:2011-08-25 11:38:31

标签: php facebook fbconnect

我已使用此代码在网站上使用facebook connect注册

<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {


    FB.init({appId: "<?=FB_APP_ID?>", status: true, cookie: true, xfbml: true});
    /* All the events registered */
    FB.Event.subscribe('auth.login', function(response) {
    // do something with response
    alert('Here');
    login();
    });
    FB.Event.subscribe('auth.logout', function(response) {
    // do something with response
    logout();
    });
};

(function() {

    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.src = document.location.protocol +'//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
    }());
function login(){
    document.location.href = "<?=SITEPATH?>users/fb_login";
}
function logout(){
    document.location.href = "<?=SITEPATH?>users/logout";
}
</script>

<fb:login-button perms="user_hometown,email,user_birthday">Login with Facebook</fb:login-button>

当用户第一次登录网站并且没有脸书会话时,这工作正常。如果我打开了facebook页面,如果我点击了fb按钮,它就不会进入fb_login page.Actually我想禁用自动登录。提前谢谢

1 个答案:

答案 0 :(得分:0)

在加载页面时和启动Facebook SDK后调用FB.logout()。你的用户可能会有些恼火,因为这也会将它们从Facebook注销。这两个登录绑定在一起,所以一旦你“连接”你的链接。

相关问题