10

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

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. 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

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

Thanks

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

4

6 回答 6

6

我在 Windows 上的 Firefox 3.5 中遇到了同样的问题,但只是在第一次登录页面时(可能是因为它是一台较慢的机器并且发生了一些奇怪的时间问题)。

我通过强制 FB 每次检查时刷新登录状态 cookie 来修复它:

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

如果没有“force=true”,有时它不会触发回调。

于 2011-05-10T00:48:30.573 回答
4

我有完全相同的问题,我解决了它在 Facebook 安全设置中禁用“安全浏览” 。保持安全浏览会强制页面为“https”,但我没有设置“安全画布 URL”,这也给了我在控制台中的很多错误。

希望这可以帮助某人:)

于 2012-10-22T20:45:46.807 回答
2

In my experience, getLoginStatus() never calls the callback in Firefox when third-party cookies are disabled.

The original poster mentioned his application is hosted on http://localhost. I've never had luck with that, and believe it will cause problems.

Just today, I've had problems where getLoginStatus is not calling the callback on any browser, unless the user is actually connected to the app! I'm hoping this is a bug on facebook's end that they will solve.

于 2011-12-13T20:27:56.893 回答
1

FB.getLoginStatus 不触发其回调的另一种可能性是使用未授权查看该应用程序的“测试”用户帐户。facebook 没有给你任何错误信息,这很糟糕。我还看到错误的 appIds 和 redirectUrls 的回调失败。

于 2012-06-15T08:39:25.030 回答
0

我知道这个问题现在有点老了,但我在寻找解决方案时遇到了它。

仔细检查您在“使用 Facebook 登录的网站”部分下的 Facebook 应用配置中设置的内容。站点 URL 域必须与您的页面与 FB.getLoginStatus(和其他相关的 auth Javascript)提供服务的域相匹配。

经过数小时的努力,我意识到我无法在新服务器上重用现有的应用程序配置,必须创建一个新应用程序来处理新服务器的网站登录。

其他答案在您的具体情况下可能同样有效,但由于可能有像我这样的其他人在这方面挣扎了一段时间,希望这能给您另一个检查的地方。在我的特殊情况下,使用正确的站点 URL 制作一个新应用程序是答案。

于 2012-07-24T13:21:52.393 回答
0

我也专门在 Chrome 中遇到了这个问题。我尝试在页面加载时调用它,并且在用户发起的操作没有成功之后调用它。

原来不是跨域问题。Chrome 中的Un-Passwordise扩展程序阻止了getLoginStatus()调用。一旦我禁用了扩展程序,它就可以完美运行,即使在页面加载时也是如此。

此处有关此问题的更多信息:Facebook iFrame App 中的 Chrome-only cross-domain scripting errs on FB.Login(..)

于 2012-01-22T20:28:53.057 回答