为什么Facebook JavaScript验证在特定计算机上不工作?

编程入门 行业动态 更新时间:2024-10-24 11:15:47
本文介绍了为什么Facebook JavaScript验证在特定计算机上不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用Facebook JavaScript API的网站,允许用户通过Facebook登录Ruby on Rails应用程序。当用户单击登录或注销时,Facebook代码进行身份验证,然后引发事件并提供具有身份验证参数的Cookie。该cookie被发送到我的服务器,我用它进行身份验证。这已经工作了一段时间。

I have a site that uses the Facebook JavaScript API to allow users to log in to a Ruby on Rails application through Facebook. When a user clicks to log in or log out, Facebook code does the authentication and then raises an event and supplies a cookie with authentication parameters. The cookie is sent to my server, and I use it to authenticate. This has been working for some time.

// Connnect with Facebook. $('.fbLogout').click(function() { FB.logout(); }); $('.fbLogin').click(function () { FB.login(); }); FB.init({appId: '163691796982300', status: true, cookie: true, xfbml: true}); FB.Event.subscribe('auth.sessionChange', function() { location.reload(); });

我最近有一台新电脑,我的网站不能从这台电脑工作。 Facebook登录界面似乎可以工作, auth.sessionChange 事件被提出,但它看起来像是从未提供的cookie,所以页面进入无限循环接收身份验证事件,刷新页面没有cookie和重复。问题似乎在这台单机上,无论使用哪种浏览器,以及我使用的是哪种操作系统。

I recently got a new computer, and my site doesn't work from this computer. The Facebook login UI seems to work, the auth.sessionChange event is raised, but it looks like the cookie is never supplied and so the page goes into an endless loop of receiving an authentication event, refreshing the page with no cookie and repeating. The problem seems be on this single computer and happens regardless of which browser I use, and which OS I use.

它适用于:

  • 朋友的PC使用Internet Explorer
  • 朋友的PC使用Firefox朋友的电脑
  • Ubuntu 10.10中的Firefox在VirtualBox中
  • 与新电脑相同的子网中的另一台电脑
  • 从Ubuntu 10.10 Live CD 64位
  • Friend's PC using Internet Explorer
  • Friend's PC using Firefox Friend's PC
  • Friends PC using Firefox in Ubuntu 10.10 in VirtualBox
  • Another PC in the same subnet as new computer
  • New computer booting from Ubuntu 10.10 live CD 64-bit

无效:

  • 新使用Internet Explorer的计算机
  • 使用Chrome的新电脑
  • 使用Firefox的新电脑
  • Ubuntu 10.10在VirtualBox中
  • New computer using Internet Explorer
  • New computer using Chrome
  • New computer using Firefox
  • New computer using Firefox in Ubuntu 10.10 in VirtualBox

这可能是由我的网卡或网络配置引起的吗?

Could this somehow be caused by my network card or network configuration?

更新:它开始工作就像失败一样神秘。

Update: It started working just as mysteriously as it was failing.

推荐答案

这可能是同样的事情我不得不处理。在代码中我看不到异步初始化:

This could be the same thing I had to deal with. In your code I can't see the asynchronous initialization:

window.fbAsyncInit = function() { FB.init({ appId : fb_appId, status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true, // parse XFBML oauth : true //enables OAuth 2.0 }); };

这是非常重要的,以保证Facebook JavaScript SDK在调用init方法之前已经完全加载。因此,它可能突然开始工作,因为浏览器已经缓存了JavaScript文件。

This is very important to guarantee that the Facebook JavaScript SDK is fully loaded before you call the init method. Therefore it may suddenly have started working, because the browser already cached the JavaScript file.

更多推荐

为什么Facebook JavaScript验证在特定计算机上不工作?

本文发布于:2023-11-11 10:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1578171.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上不   计算机   工作   在特定   Facebook

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!