Created
November 19, 2011 23:33
-
-
Save joedevon/1379539 to your computer and use it in GitHub Desktop.
Facebook get user Login Status
This file contains 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
<html lang="en" prefix="og: http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"> | |
<head><title>Hello Facebook</title></head> | |
<body> | |
<div id="fb-root"></div> | |
<script type="text/javascript"> | |
window.fbAsyncInit = function() { | |
FB.init({ | |
appId: YOUR_APP_ID_HERE, | |
channelURL: '//www.example.com/channel.html', // Channel File | |
status: true, // check login status | |
cookie: true, // enable cookies to allow the server to access the session | |
xfbml: true, // parse XFBML | |
oauth: true // enables OAuth 2.0 | |
}); | |
// Additional initialization code here | |
FB.getLoginStatus(function(response) { | |
if (response.authResponse) { | |
// logged in and connected user, someone you know | |
console.log('you know this user!!'); | |
} else { | |
// no user session available, someone you dont know | |
console.log('Howdy Stranger!'); | |
} | |
}); | |
// END additional initialization | |
}; | |
// Load the SDK Asynchronously | |
(function(d){ | |
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} | |
js = d.createElement('script'); js.id = id; js.async = true; | |
js.src = "//connect.facebook.net/en_US/all.js"; | |
d.getElementsByTagName('head')[0].appendChild(js); | |
}(document)); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment