Facebook FB.login对话框失败并显示错误

时间:2012-11-29 10:23:14

标签: facebook login

New to Facebook apps, developing a test app using JavaScript:
  1. 我以app管理员(普通用户)的身份登录Facebook。

  2. 我到了FB.getLoginStatus返回response.status ==='not_authorized'的地步。

    1. 我叫FB.login。
    2. 我得到一个弹出窗口“发生错误。请稍后再试。”

    3. FB.login使用response.authResponse = null回调。

    4. 控制台日志显示“日志:无法找到回调1”。

  3. 我在所有浏览器中都遇到同样的错误...     帮助

    Here is the relevant code - I replaced actual strings by ######:
    
    <div id="fb-root"></div>
    
    <script>
    
    var init_status = 1;
    var login_status = 1;
    var signedRequest = ' ';
    
    window.fbAsyncInit = function() {
      FB.init({
        appId      : '######', // App ID from the App Dashboard
        channelUrl : 'http://#####/channel.php', // Channel File for x-domain communication
        status     : true, // check the login status upon init?
        cookie     : true, // set sessions cookies to allow your server to access the session?
        xfbml      : false  // parse XFBML tags on this page?
      });
      getLoginStatus();
    };
    
    // Load the SDK Asynchronously:
    (function(d){
      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.js";
      ref.parentNode.insertBefore(js, ref);
    }(document));
    
    call_proceed1_when_ready(); // wait for init_status > 1
    
    function proceed1() {
    
      // Login the user and/or authenticate with app, if necessary:
      if (init_status > 2) {
        login ();
      } else {
        login_status = 2;
      }
    
      call_proceed2_when_ready(); // wait for login_status > 1
    
    } //proceed1
    
    function proceed2() {
    
      alert('DONE');
    
    } //proceed2
    
    ////////////////
    // FUNCTIONS: //
    ////////////////
    
    function call_proceed1_when_ready () {
      if (init_status > 1) {
        proceed1();
      } else {
        setTimeout(call_proceed1_when_ready, 500); // 0.5 second
      }
    }
    
    function call_proceed2_when_ready () {
      if (login_status > 1) {
        proceed2();
      } else {
        setTimeout(call_proceed2_when_ready, 500); // 0.5 second
      }
    }
    
    function getLoginStatus() {
      FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
          signedRequest = response.authResponse.signedRequest;
          init_status = 2;
        } else if (response.status === 'not_authorized') {
          init_status = 3;
        } else {
          init_status = 4;
        }
      });
    }
    
    function login() {
      FB.login(function(response) {
        if (response.authResponse) {
          login_status = 2;
        } else {
          login_status = 3;
        }
      });
    }
    
    </script>
    

0 个答案:

没有答案