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

コメントの 1 つで @CBroe が言及したように、FB.loginポップアップ ブロッカーが原因で、ユーザー インタラクションの外で呼び出すことはできません。

代わりに、ボタン/リンクを利用可能にして、この呼び出しを行いますFB.login

于 2012-11-17T04:03:07.777 に答える