Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Ariestattoo
Created January 7, 2014 21:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Ariestattoo/8307135 to your computer and use it in GitHub Desktop.
Save Ariestattoo/8307135 to your computer and use it in GitHub Desktop.
Facebook get login status
FB.getLoginStatus(function (response) {
console.log(response);
if (response.status === 'connected') {
// updatePermissions();
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
FB.login(function (response) {
// handle the response
}, {scope: 'publish_actions'});
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
FB.login(function (response) {
// handle the response
}, {scope: 'publish_actions'});
}
});
FB.Event.subscribe('auth.authResponseChange', function (response) {
// Here we specify what we do with the response anytime this event occurs.
if (response.status === 'connected') {
console.log('status connected',response);
// The response object is returned with a status field that lets the app know the current
// login status of the person. In this case, we're handling the situation where they
// have logged in to the app.
testPermissions();
} else if (response.status === 'not_authorized') {
// In this case, the person is logged into Facebook, but not into the app, so we call
// FB.login() to prompt them to do so.
// In real-life usage, you wouldn't want to immediately prompt someone to login
// like this, for two reasons:
// (1) JavaScript created popup windows are blocked by most browsers unless they
// result from direct interaction from people using the app (such as a mouse click)
// (2) it is a bad experience to be continually prompted to login upon page load.
FB.login(function (response) {
// handle the response
}, {scope: 'publish_actions'});
} else {
// In this case, the person is not logged into Facebook, so we call the login()
// function to prompt them to do so. Note that at this stage there is no indication
// of whether they are logged into the app. If they aren't then they'll see the Login
// dialog right after they log in to Facebook.
// The same caveats as above apply to the FB.login() call here.
FB.login(function (response) {
// handle the response
}, {scope: 'publish_actions'});
}
});
@sourabhanand77
Copy link

{
status: 'connected',
authResponse: {
accessToken: '...',
expiresIn:'...',
signedRequest:'...',
userID:'...'
}
}

@Redyone204
Copy link

<script src="https://gist.github.com/Ariestattoo/8307135.js"></script>

@Redyone204
Copy link

+---[RSA 4096]----+
| . ..o . |
| . = o.+E |
| . + o *=. |
| o = +++ o |
| . + = S . o o |
| o B = o . * |
| + * + + + . |
| * B.o |
| Boo |
+----[SHA256]-----

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment