[ad_1]
MORE TO COME
// This is called with the results from from FB.getLoginStatus(). var aslAccessToken = ''; var aslPlatform = ''; function statusChangeCallback(response) { console.log(response); if (response.status === 'connected') { if(response.authResponse && response.authResponse.accessToken && response.authResponse.accessToken != ''){ aslAccessToken = response.authResponse.accessToken; aslPlatform = 'facebook'; tryLoginRegister(aslAccessToken, aslPlatform, ''); }
} else { // The person is not logged into your app or we are unable to tell. console.log('Please log ' + 'into this app.'); } }
function cancelLoginPermissionsPrompt() { document.querySelector("#pm-login-dropdown-options-wrapper__permissions").classList.add('u-d-none'); document.querySelector("#pm-register-dropdown-options-wrapper__permissions").classList.add('u-d-none'); document.querySelector("#pm-login-dropdown-options-wrapper").classList.remove('u-d-none'); document.querySelector("#pm-register-dropdown-options-wrapper").classList.remove('u-d-none'); }
function loginStateSecondChance() { cancelLoginPermissionsPrompt(); FB.login( function(response) {
}, { scope: 'email', auth_type: 'rerequest' } ); }
// 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) {
var permissions = null;
FB.api('/me/permissions', { access_token: response.authResponse.accessToken, }, function(response2) { if(response2.data) { permissions = response2.data; } else { permissions = []; }
var emailPermissionGranted = false; for(var x = 0; x < permissions.length; x++) { if(permissions[x].permission === 'email' && permissions[x].status === 'granted') { emailPermissionGranted = true; } } if(emailPermissionGranted) { statusChangeCallback(response); } else { document.querySelector("#pm-login-dropdown-options-wrapper__permissions").classList.remove('u-d-none'); document.querySelector("#pm-register-dropdown-options-wrapper__permissions").classList.remove('u-d-none'); document.querySelector("#pm-login-dropdown-options-wrapper").classList.add('u-d-none'); document.querySelector("#pm-register-dropdown-options-wrapper").classList.add('u-d-none'); } }); }); } window.fbAsyncInit = function() { FB.init({ appId : 392528701662435, cookie : true, xfbml : true, version : 'v3.3' }); FB.AppEvents.logPageView(); FB.Event.subscribe('auth.login', function(response) { var permissions = null; FB.api('/me/permissions', { access_token: response.authResponse.accessToken, }, function(response2) { if(response2.data) { permissions = response2.data; } else { permissions = []; } var emailPermissionGranted = false; for(var x = 0; x < permissions.length; x++) { if(permissions[x].permission === 'email' && permissions[x].status === 'granted') { emailPermissionGranted = true; } } if(emailPermissionGranted) { statusChangeCallback(response); } else { document.querySelector("#pm-login-dropdown-options-wrapper__permissions").classList.remove('u-d-none'); document.querySelector("#pm-register-dropdown-options-wrapper__permissions").classList.remove('u-d-none'); document.querySelector("#pm-login-dropdown-options-wrapper").classList.add('u-d-none'); document.querySelector("#pm-register-dropdown-options-wrapper").classList.add('u-d-none'); } }); }); }; (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 = "https://connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));
Leave a Reply