Bjorn
Bjorn

Reputation: 71930

How does one handle a Facebook Connect timeout

I don't see any way to respond to a timeout issue if Facebook is down or not responding when I use FB.init. There's no option here: http://wiki.developers.facebook.com/index.php/JS_API_M_FB.Bootstrap.Init_2

Would be nice if there were some way to respond to errors like you can with normal xmlhttprequests. Is there such a thing with Facebook Connect?

Upvotes: 2

Views: 1736

Answers (1)

Portman
Portman

Reputation: 31995

As far as I know, you cannot gracefully handle timeouts with FB.init.

That's why I never use FB.init directly. Instead, I always call FB_RequireFeatures. This wraps the FB.init call so that I can deal with errors and degrade gracefully. What I do is write my own function that checks whether Facebook Connect initialized correctly and then does something appropriate if it did not.

For example:

FB_RequireFeatures(["Connect"], function() {
  FB.init("API_KEY", "xd_receiver.htm");
  myPostConnectFunction();
});

function myPostConnectFunction() {
  // Check for success of FBconnect, and deal with errors accordingly.
};

If that seems hacky, well... it is. :-)

Upvotes: 3

Related Questions