Login with Facebook Script

<script>
window.fbAsyncInit = function() {
FB.init({
appId:’App_id’,
cookie:true,
status:true,
xfbml:true,
oauth:true
});
};

// Load the SDK Asynchronously
(function(d){
var js, id = ‘facebook-jssdk’; if (d.getElementById(id)) {return;}
js = d.createElement(‘script’); js.id = id; js.async = true;
js.src = “//connect.facebook.net/en_US/all.js”;
d.getElementsByTagName(‘head’)[0].appendChild(js);
}(document));
</script>
<script type=”text/javascript”>
function fblogin()
{
FB.login(function(response) {
if (response.authResponse) {
FB.api(‘/me’, function(response) {
console.log(response.id+” + response.email + ‘.’);
var a=document.getElementById(‘fbid’).value=response.id;
var b=document.getElementById(‘fbemail’).value=response.email;
document.forms[‘fbform’].submit();
});
} else {
console.log(‘User cancelled login or did not fully authorize.’);
}
}, {scope: ’email’});
}
</script>

<form action=”facebooklogin.php” method=”post” name=”fbform”>
<input type=”hidden” name=”fbid” id=”fbid” />
<input type=”hidden” name=”fbemail” id=”fbemail” />
</form>
<div id=”fb-root”></div>
<a href=”javascript:fblogin();”>
<p>login with Facebook</p>
</a>

………………………………………….
facebooklogin.php
print_r($_POST);

Similar Posts

4 Comments

  1. Nice. This coding teach me some good ideas about FB log in coding details. Such a good information.

  2. Face book gets popularized more than twitter. because fb is user friendly. So more peoples like this a lot. This coding much needed. but i little confused here.

  3. I am 14 year old only. Now i started to use FB. FB usage is very simple. But a new user like me need to know more about it.So please share that kind of post.

Leave a Reply

Your email address will not be published. Required fields are marked *