function getUserData() { FB.api("/me?fields=id,name,email,first_name,last_name,link,locale", function (response) { if (response.email != '') { storeFacebookDetails(response); } else { $('#signinAlert').html("Please provide your email address"); $('#signinAlert').show(); grecaptcha.reset(recaptcha1); setTimeout(function () { $("#signinAlert").hide(); }, 3000); } }); } function storeFacebookDetails(data) { var currentLocation = window.location; $.ajax({ url: videobaseurl + '/ajax/ajaxSocialSignUp.php', dataType: "json", method: "POST", data: {"social_flag": "fb", "social_data": data}, success: function (response) { if (response.flag == 1) { window.location.href = response.rurl; } else { console.log(response); } }, error: function (response) { console.log(response); } }); } window.fbAsyncInit = function () { //SDK loaded, initialize it // facebook @nizamuddin@tutorialspoint.com FB.init({ appId: "216851252183948", xfbml: true, version: "v2.9" }); //check user session and refresh it FB.getLoginStatus(function (response) { if (response.status === 'conected') { //user is authorized } }); }; $(document).ready(function () { // startApp; //Load the Javascript SDk (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_GB/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); $("#btnFacbookLogin").on('click', function () { //do the login FB.login(function (response) { if (response.authResponse) { $("#btnFacebookLogin").css("display", "none"); getUserData(); } }, {scope: 'email,public_profile', return_scopes: true}); }); $("#btnGoogleLogin").on('click', function () { startApp(); }); }); var auth2; var startApp = function () { gapi.load('auth2', function () { // Retrieve the singleton for the GoogleAuth library and set up the client. auth2 = gapi.auth2.init({ client_id: '59018309344-4u7p1494898pnmkrfos13huo94b5og46.apps.googleusercontent.com', cookiepolicy: 'single_host_origin', scope: 'profile' // Request scopes in addition to 'profile' and 'email' //scope: 'additional_scope' }); attachSignin(document.getElementById('btnGoogleLogin')); }); }; // Google Social Qries var googleUser = {}; function attachSignin(element) { var response = new Object(); auth2.attachClickHandler(element, {}, function (googleUser) { var googleProfile = googleUser.getBasicProfile(); response.id = googleProfile.getId(); response.name = googleProfile.getName(); response.given_name = googleProfile.getGivenName(); response.family_name = googleProfile.getFamilyName(); response.email = googleProfile.getEmail(); response.image_url = googleProfile.getImageUrl(); if (response.email != '') { storeGoogleDetails(response); } else { $('#signinAlert').html("Please provide your email address"); $('#signinAlert').show(); grecaptcha.reset(recaptcha1); setTimeout(function () { $("#signinAlert").hide(); }, 3000); } }, function (error) { }); } function storeGoogleDetails(resData) { var currentLocation = window.location; var gData = {"social_flag": "google", "social_data": resData}; $.ajax({ url: videobaseurl + '/ajax/ajaxSocialSignUp.php', dataType: "json", method: "POST", data: gData, success: function (response) { if (response.flag == 1) { window.location.href = response.rurl; } else { console.log(response); } }, error: function (response) { console.log(response); } }); }