FB.getLoginStatus永远不会在Facebook的JavaScript SDK中触发回调函数 [英] FB.getLoginStatus never fires the callback function in Facebook's JavaScript SDK

查看:102
本文介绍了FB.getLoginStatus永远不会在Facebook的JavaScript SDK中触发回调函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先调用FB.init(在</body>之前)然后再执行FB.getLoginStatus(callback)的简单操作不会触发回调函数.

The simple thing of calling FB.init (right before </body>) and then FB.getLoginStatus(callback) doesn't fire the callback function.

经过一些调试后,我认为SDK停留在加载"(即FB.Auth._loadState == 'loading')阶段,并且从未进入加载"状态,因此所有回调都排队等待,直到SDK加载完毕. 如果我在调试过程中强行触发已加载"事件(如果您感兴趣,请使用FB.Event.fire('FB.loginStatus', 'loaded')触发),则回调将被正确调用.

After some debugging, I think the SDK is stuck in the "loading" (i.e. FB.Auth._loadState == 'loading') phase and never gets to "loaded", so all callbacks are queued until the SDK has loaded. If I force-fire the "loaded" event during debugging - with FB.Event.fire('FB.loginStatus', 'loaded') in case you're intersted - then the callbacks are invoked correctly.

可能相关的其他详细信息:

Extra details that might be relevant:

  1. 我的应用是一个Facebook iframe应用(通过apps.facebook.com/myapp加载)
  2. 我正在使用IE9.在Chrome中发生相同的行为
  3. 该应用程序托管在 http://localhost
  1. My app is a facebook iframe app (loaded via apps.facebook.com/myapp)
  2. I'm using IE9. The same behavior happens in Chrome
  3. The app is hosted in http://localhost

这是怎么回事?为什么SDK无法加载?

What's going on? Why is the SDK never gets to loaded?

谢谢

更新:刚刚在Chrome上尝试了一下,它就起作用了(不确定为什么以前不起作用).在IE中仍然无法使用

UPDATE: Just tried it on Chrome and it worked (not sure why it didn't work before). Still doesn't work in IE

推荐答案

我在Windows上的Firefox 3.5中也遇到了同样的问题,但仅在首次登录页面时出现(可能是因为这是一台速度较慢的机器,并且存在一些奇怪的计时问题还在继续).

I had this same problem in Firefox 3.5 on Windows, but only on the very first log in to the page (probably because it was a slower machine and there was some weird timing issues going on).

我通过强制FB在每次检查时刷新登录状态cookie来解决此问题:

I fixed it by forcing FB to refresh the login status cookie every time it checks:

FB.getLoginStatus(callback, true); //second argument forces a refresh from Facebook's server. 

没有"force = true",有时不会触发回调.

Without "force=true", sometimes it wouldn't fire the callback.

这篇关于FB.getLoginStatus永远不会在Facebook的JavaScript SDK中触发回调函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆