Facebook JS sdk Oauth onload



我尝试使用Facebook JS SDK时遇到了一个问题。

我希望页面加载后,用户点击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触发器是加载的,所以如果用户已经登录并刚刚到达页面,他会直接发送到下一个页面,我不希望这样!我希望用户先看到页面,单击,然后登录/或不登录,然后转到下一页有人知道怎么做吗?

(用户登录后没有点击事件可能导致FB重新加载页面)

已找到!

将状态设为假

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

很抱歉打扰

最新更新