0

我尝试使用 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 触发 onload 的事实,所以如果用户已经登录并且刚刚到达页面,他会直接发送到下一页,我不希望这样!我希望用户首先看到该页面,单击,然后登录/或不登录并转到下一页有人知道如何做到这一点吗?

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

4

1 回答 1

0

成立 !

将状态设置为 false

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

抱歉打扰

于 2013-07-04T05:22:06.057 回答