// This is called with the results from from FB.getLoginStatus(). function statusChangeCallback(response,success_callback) { 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. if(success_callback != undefined){ success_callback(); } } else if (response.status === 'not_authorized') { // The person is logged into Facebook, but not your app. document.getElementById('status').innerHTML = 'Please log ' + 'into this app.'; } else { // The person is not logged into Facebook, so we're not sure if // they are logged into this app or not. document.getElementById('status').innerHTML = 'Please log ' + 'into Facebook.'; } } // 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(success_callback) { FB.getLoginStatus(function(response) { statusChangeCallback(response,success_callback); }); } // Here we run a very simple test of the Graph API after login is // successful. See statusChangeCallback() for when this call is made. function server_facebook_login() { console.log('Welcome! Fetching your information.... '); FB.api('/me?fields=name,email', function(response) { var return_path = $('#post_login_return_path').val(); $.post(wz_config_ajax_url + "customer_actions.php", {'do':'login_facebook','email':response.email,'facebook_id':response.id,'facebook_name':response.name}); console.log('Successful login for: ' + response.name); console.log(response); //document.getElementById('status').innerHTML = 'Thanks for logging in, ' + response.name + '!'; }); } function server_facebook_login_redirect() { console.log('Welcome! Fetching your information.... '); FB.api('/me?fields=name,email', function(response) { var return_path = $('#post_login_return_path').val(); $.post(wz_config_ajax_url + "customer_actions.php", {'do':'login_facebook','email':response.email,'facebook_id':response.id,'facebook_name':response.name}, function(data){ if(data == 'SUCCESS'){ if(return_path != ''){ console.log('Redirecting...'); window.location=wz_config_base_url+return_path+'/'+business_id+"/"+menu_id+"/"; } else { console.log('Redirecting...'); window.location=wz_config_base_url+business_id+"/"+menu_id+"/"; } } else if(data == 'ACCOUNT_SETUP'){ console.log('Redirecting...'); window.location=wz_config_base_url+'customer_modify_account'+'/'+business_id+"/"+menu_id+"/checkout/"; } }); console.log('Successful login for: ' + response.name); console.log(response); //document.getElementById('status').innerHTML = 'Thanks for logging in, ' + response.name + '!'; }); }