0

我已将以下代码放在脑海中以检查会话:

<script type="text/javascript">
            FB.getLoginStatus(function(response) {
              if (response.session) {
                alert('I am logged in');
              } else {
                alert('I am logged out');
              }
            });
    </script>

但是,它不会在页面加载时执行,这是为什么呢?

4

1 回答 1

1

确保你有:

FB.init({
    appId  : APP_ID, // Your FB app ID from www.facebook.com/developers/
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
});

在脚本中的任何其他 FB 引用之前(使用 window.onload 或类似的)和

<DIV id="fb-root"></div> 

<body>节中。

于 2011-04-24T04:29:03.030 回答