var FBConnected = false; var UserObj = {}; // This is called with the results from from FB.getLoginStatus(). function statusChangeCallback(response) { console.log('statusChangeCallback'); console.log(response); // The response object is returned with a status field that lets the // app know the current login status of the person. // Full docs on the response object can be found in the documentation // for FB.getLoginStatus(). if (response.status === 'connected') { // Logged into your app and Facebook. testAPI(); } else if (response.status === 'not_authorized') { } else { } } // This function is called when someone finishes with the Login // Button. See the onlogin handler attached to it in the sample // code below. function checkLoginState() { FB.getLoginStatus(function(response) { statusChangeCallback(response); }); } // Load the SDK asynchronously (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); } (document, 'script', 'facebook-jssdk')); // Here we run a very simple test of the Graph API after login is // successful. See statusChangeCallback() for when this call is made. function testAPI() { console.log('Welcome! Fetching your information.... '); FB.api('/me', {fields: 'name,first_name,last_name,email,id'}, function(response) { /* for (n in response) { console.log(n + ' = ' + response[n]); } console.log ("==================================="); console.log(JSON.stringify(response)); console.log ("==================================="); */ console.log('Full Name: ' + response.name); console.log('First Name: ' + response.first_name); console.log('Last Name: ' + response.last_name); console.log('Email: ' + response.email); console.log('ID: ' + response.id); // document.getElementById('status').innerHTML = 'Thanks for logging in, ' + response.name + '!'; FBConnected = true; console.log ("doOtherStuff(response,'facebook');"); doOtherStuff (response, "facebook"); }); } function doLoginFacebook () { $('#responce').html (""); $('#responce').html ('