Skip to content

Instantly share code, notes, and snippets.

@jescalan
Created December 24, 2011 23:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jescalan/1518505 to your computer and use it in GitHub Desktop.
Save jescalan/1518505 to your computer and use it in GitHub Desktop.
Facebook getLoginStatus Example
<!DOCTYPE html>
<html>
<head>
<title>Facebook getLoginStatus Example</title>
</head>
<body>
<p>Check out the console to see if anything appears.</p>
<p>HERE'S THE CODE:</p>
<pre>
$(function(){
FB.init({ apiKey: '203642573046113', status: true });
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
console.log(response);
} else if (response.status === 'not_authorized') {
console.log('not connected to app');
} else {
console.log('not logged in to fb');
}
});
});
</pre>
<div id='fb-root'></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
$(function(){
FB.init({ apiKey: '203642573046113', status: true });
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
console.log(response);
} else if (response.status === 'not_authorized') {
console.log('not connected to app');
} else {
console.log('not logged in to fb');
}
});
});
</script>
</body>
</html>
@wenwangcode
Copy link

I was wondering where's the "FB" defined?

@jebog
Copy link

jebog commented May 12, 2017

It's defined here http://connect.facebook.net/en_US/all.js

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