Thursday 3 April 2014

Facebook Login with JavaScript

Follow Simple Steps to Integrate "Facebook Login" with JavasScript in your Web Application.

  • Login in
  • "Create a New App" in
  • Fill all required Information
  • Settings => App PlateForm=>Click on "Website" then add detail
  • In "Status & Review", Click on "Yes" to activate for public

Get the "App Id" and use in Following Example
        <title>Facebook Login Integration with JavaScript</title>
        <script src="//"></script>

        <div id="fb-root">
            window.fbAsyncInit = function() {
                    appId      : 'XXXXXXXX',//your appid
                    status     : true, 
                    cookie     : true,
                    xfbml      : true,
                    oauth      : true                    
                FB.Event.subscribe('auth.authResponseChange', function(response) {                    
                    // Here we specify what we do with the response anytime this event occurs. 
                    if (response.status === 'connected') {
                    } else if (response.status === 'not_authorized') {
                        // In this case, the person is logged into Facebook, but not into the app, so we call                        
                    } else {
                        // In this case, the person is not logged into Facebook, so we call the login()                         
            function saveuserdetail() {
                //console.log('Welcome!  Fetching your information.... ');
                FB.api('/me', function(response) {                    
                        type: "POST",
                        url: '/url_to_save_detail',
                        data: response,
                        success: function(msg){
                        dataType: 'json'
                var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                js = d.createElement('script'); = id; js.async = true;
                js.src = "//";
        <div class="fb-login-button">
Login with Facebook</div>

Facebook Login URL:
websiteLoginURL: After login which page of your website should redirect.
appId: Application Id of