Then facebooklogoin.js:
//Edited by dkp
// Load the SDK Asynchronously
(function (d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
ref.parentNode.insertBefore(js, ref);
} (document));
// Additional JS functions here
window.fbAsyncInit = function () {
FB.init({
appId: '408537542603090',
channelUrl: '//http://yoururl.com/channel.html',
status: true,
cookie: true,
xfbml: true
});
FB.getLoginStatus(function (response) {
if (response.status == 'connected') {
// window.location = "http://dubaibricks.com/siteuser/home.aspx";
//connected
//alert("You are already login with facebook userid and password.");
} else if (response.status == 'not_authorized') {
alert("Please use normal signin with userid and password!Otherwise Provide us to fetch necessary informations from facebook like Email,date of birth.These are all private not public!")
FB.logout(function (response) {
//logout
alert("You are Signout successfully!Thank you.");
});
// not_authorized
} else {
// not_logged_in
//window.location = "http://96.0.68.12/";
}
});
};
function login() {
FB.login(function (response) {
if (response.authResponse) {
Getloginuserdetails();
} else {
}
}, { scope: 'email,user_birthday,user_location' });
}
function Getloginuserdetails() {
FB.api('/me', function (response) {
//alert('Welcome ' + response.first_name + ',' + response.last_name + ',' + response.gender + ',' + response.email + ',' + response.birthday);
var date = new Date();
var curyear = date.getFullYear();
//var curmonth = date.getMonth()+1;
//var curdate = date.getDate();
//var datediff = parent()
var yeardiff = parseInt(curyear) - parseInt(response.birthday.substr(6, 4))
if (yeardiff < 18) {
alert("Your age must be 18 years or above")
FB.logout(function (response) {
// user is now logged out
});
}
else {
var data = response.first_name + "|" + response.last_name + "|" + response.email + "| |";
data += response.gender + "| |" + yeardiff + "|";
$.ajax({
type: "POST",
async: false,
url: "Handler/registration.ashx",
data: data,
beforeSend: function (xhr) { xhr.setRequestHeader("X-AjaxPro-Method", "REGISTRATION-FB"); },
success: function (response) {
window.location = response;
},
error: function (xhr) {
//alert(xhr.status)
//alert(xhr.statusText);
//alert(xhr.responseText);
alert("!Sorry im am not fething your essential information.Please Try again later.");
}
});
}
});
}