最近FB SDK更改后Facebook oauth失败

时间:2011-12-21 11:02:53

标签: facebook oauth-2.0 facebook-oauth

经过与Facebook OAuth 2的相当令人沮丧的回合,并且我的Facebook Connect登录完全在我的网站上休息(www.thegameeffect.com),我转向StackOverflow的明智思想希望得到一些指导。

在1-2个月前,事情进展得相当不错,但最近我遇到了问题。基本上,我已按照FB开发者网站的步骤进行操作,并从此处点击其他几个帮助指南,例如此链接:(http://stackoverflow.com/questions/8537007/facebook-cookie-and-oauth-2 -0-改变)并且遗憾地没有运气。

我的FB.Init代码如下所示:

        <div id="fb-root"></div>
        <script type="text/javascript">
            window.fbAsyncInit = function () {
                FB.init({ appId: '145290112183820', status: true, cookie: true, xfbml: true, channelUrl: 'http://www.thegameeffect.com/fbchannel.html' });
                //, oauth:true
            };

            (function () {
//                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";
//                d.getElementsByTagName('head')[0].appendChild(js);
                var e = document.createElement('script'); e.async = true;
                e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js#xfbml=1';
                document.getElementById('fb-root').appendChild(e);
            } ());

        </script> 

我已经尝试了所有这些变体,包括oauth:true,排除了channelurl,顶部取消注释的自调用函数,以及当我尝试登录时发生的所有事情都是auth窗口弹出,然后消失。单击标题左上角的FB图标时执行的代码如下:

    FB.login(function (response) {                    
         if (response.session) {   
         // do server side work (this never gets hit)
         }
    });

有什么建议吗?

3 个答案:

答案 0 :(得分:1)

一些细微的更改将使您的代码有效:

  

window.fbAsyncInit = function(){

     

FB.init({appId:'145290112183820',状态:true,cookie:true,   xfbml:true,channelUrl:   'http://www.thegameeffect.com/fbchannel.html', oauth:true });

        };
     

     

FB.login(功能(响应){
           if( response.authResponse ){
           }       });

答案 1 :(得分:1)

所以,经过一番挖掘和大量的调试后,我终于找到了解决方案。感谢manishekhawat和服务器端,我能够得到javascript方面的工作,感谢这个很棒的帖子:

http://amirrajan.net/Blog/facebook-oauth-authentication-and-iframe-apps

对于任何在ASP.NET中使用新的oAuth cookie的人来说,这是一个了不起的教程!

再次感谢你今天的帮助;我很高兴终于让一切工作正常。

答案 2 :(得分:0)

更改,

FB.getLoginStatus(function(response) {
  if (response.session) { ........................
  }

通过

    FB.getLoginStatus(function(response) {
      if (response.authResponse) {
........................
      }

My facebook app make Infinite loop in sdk 3.1.1