Created
May 11, 2011 14:52
-
-
Save ashaw/966591 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jankyLoginStatus = function(cb) { | |
var that = this; | |
var statusObj = {}; | |
// see if we can get "me" | |
FB.api('/me', function(response) { | |
// we can't get me. Verify it's an OAuthException, and then sub in notConnected. | |
if (response['error'] && response['error']['type'] === "OAuthException") { | |
statusObj['status'] = "notConnected"; | |
FB.logout(); // just to make sure we don't have stale cookies | |
return cb(statusObj); | |
} else { | |
// they have a session and are connected. | |
// stash a copy of "me" | |
that.me = response; | |
// stash the session so we can store tokens, etc. | |
statusObj['status'] = "connected" | |
statusObj['session'] = FB.getSession(); | |
return cb(statusObj); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment