繁体   English   中英

Facebook登录错误Javascript

[英]Facebook login error Javascript

我当时使用Facebook登录没有问题。。但是,下一个错误开始神秘地显示在Firebug控制台中,现在我无法登录。

(new Date).addMonths不是函数FB.provide('',{getLoginStatus:function ... signed_request,code'});返回a;}}}));

我正在使用Javascript SDK。

<div id='fb-root'></div>
  <script>
    //<![CDATA[
      window.fbAsyncInit = function() {
      FB.init({
      appId      : '205160466168923', // App ID
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      oauth      : true, // enable OAuth 2.0
      xfbml      : true  // parse XFBML
      });
      //channelUrl : '//www.clasesd.com/channel.html', // Channel File

      // Additional initialization code here
      };

      // Load the SDK Asynchronously
      (function(d){
      var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
      js = d.createElement('script'); js.id = id; js.async = true;
      js.src = "//connect.facebook.net/en_US/all.js#**oauth=1**&appId=205160466168923&xfbml=1";
      d.getElementsByTagName('head')[0].appendChild(js);
      }(document));
    //]]>
  </script>

这就是我用来触发登录的方法

FB.login(function(response) {
if (response.authResponse) {
    FB.api('/me', function(response) {
    console.log('Good to see you, ' + response.name + '.');
    window.location = redirect_url;
    });
} else {
    console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'email, offline_access, publish_stream, user_events'});

});

已知问题,请参见http://developers.facebook.com/bugs/149848578458727

如关于该问题的评论所述,这是一种解决方法:

在调用FB.init()之前,放置以下代码

Date.prototype.addMonths = function(n) {
    this.setMonth(this.getMonth()+n);
    return this;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM