Login/ Register With Facebook

Step1:

 Please insert the Following script inside body tag of your login/register page. 

<div id="fb-root" style="float:left; width:1px;"></div>

<script>
window.fbAsyncInit = function() {
    FB.init({
       appId: 'Enter your API here',
       cookie: true,
       xfbml: true,
       oauth: true
    }); 
};


(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());

function fblogin(){
FB.login(function(response){
if (response.authResponse) {
window.location='validatefb.php';
}
},{scope: 'publish_stream'});
}
</script>

Step 2:

Please insert login with face book button and write down the following code.

<img border="0" src="images/login_facebook.png" onClick="fblogin();"
 border="0" style="cursor:pointer">
 
 

Step3:

validatefb.php  will check if the user has already register with your system or not. If the user registered before then the system will take the user to welcome page or it will take the user to register page.

 

 

Comments

Popular posts from this blog

Linux Shortcuts

Petra, Jordan

PayPal integration in PHP