0

基本上我是使用 facebook api 的新手,我在尝试让我的代码正常工作时遇到问题,如果用户尚未登录,以下代码应该会提供提示,但我不确定它有什么问题。 http://apps.facebook.com/biographyscribe/

    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
          xmlns:fb="https://www.facebook.com/2008/fbml"> 
    <head>
      <title></title>
    </head>
    <body>
    <p>hello</p>
    <script type="text/javascript">
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '490455294310717', // App ID from the App Dashboard
          channelUrl: 'channel.php',
          status     : true, // check the login status upon init?
          cookie     : true, // set sessions cookies to allow your server to 
          xfbml      : true  // parse XFBML tags on this page?
        });

        // Additional initialization code such as adding Event Listeners goes here

        FB.getLoginStatus(function(response) {
            if (response.status === 'connected') {
                var uid = response.authResponse.userID;
                accessToken = response.authResponse.accessToken;
            } else if (response.status === 'not_authorized'){

                FB.login();

                } else {
                    window.top.location = 'https://www.facebook.com/index.php';
                }
        });

      };

      // Load the SDK's source Asynchronously
      (function(d, debug){
         var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement('script'); js.id = id; js.async = true;
         js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
         ref.parentNode.insertBefore(js, ref);
       }(document, /*debug*/ false));
    </script>

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

    </body>

</html

>
4

1 回答 1

0

正如@CBroe 在其中一条评论中提到的那样,由于弹出窗口阻止程序,FB.login无法在用户交互之外调用。

相反,提供一个按钮/链接,并进行此调用FB.login

于 2012-11-17T04:03:07.777 回答