0

在与 Facebook OAuth 2 进行了一次相当令人沮丧的较量之后,我的 Facebook Connect 登录完全在我的网站 (www.thegameeffect.com) 上中断,我转向 StackOverflow 的聪明头脑,希望得到一些指导。

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

我的 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,顶部未注释的自调用函数,当我尝试登录时仍然发生的所有事情是身份验证窗口短暂弹出,然后消失. 单击标题左上角的 FB 图标时执行的代码如下:

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

有什么建议么?

4

3 回答 3

1

一些小的更改将使您的代码正常工作:

window.fbAsyncInit = function () {

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

        };

FB.login(function (response) {
if ( response.authResponse ) {
} });

于 2011-12-21T11:27:49.800 回答
1

因此,经过更多的挖掘和大量的调试,我终于找到了解决方案。多亏了 manishekhawat,我才能够让 javascript 端工作,而服务器端多亏了这篇很棒的帖子:

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

对于任何在 ASP.NET 中遇到新的 Facebook oAuth cookie 问题的人,这是一个了不起的教程!

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

于 2011-12-22T00:05:05.307 回答
0

改变,

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

经过

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

我的 facebook 应用程序在 sdk 3.1.1 中创建无限循环

于 2011-12-21T17:57:01.040 回答