<div><a href=’javascript:void(null);’ onclick=”login();”>Signup/ login through facebook</a></div>
<div id=”fb-root”></div>
<script src=”http://connect.facebook.net/en_US/all.js”></script>
1. Include the above facebook all.js first.
<script>
2. Initialize the facebook app settings.
jQuery(function() {
FB.init({
appId : ” <12356666>”,
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
});.
//function to do the signup
function login() {
FB.getLoginStatus(function(response) {
if (response.status == ‘connected’) {
getCurrentUserInfo(response)
} else {
FB.login(function(response) {
if (response.authResponse){
getCurrentUserInfo(response)
} else {
alert(‘Auth cancelled.’)
}
}, { scope: ’email,user_birthday’ }); //Ask additional information
}
});
}
//Get current logged user info
function getCurrentUserInfo() {
FB.api(‘/me’, function(response) {
if (response) {
var oTabData = new Object();
oTabData.firstname = response.first_name;
oTabData.lastname = response.first_name;
oTabData.email = response.email;
oTabData.dob = response.birthday;
oTabData.gender = response.gender;
studentlyaccountCreate(oTabData);
}
else {
jQuery(‘#error’).html(‘<span>**There is something went wrong…Try again…</span>’);
}
});
}
</script>