Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to implement facebook login/signup functionality.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 179
    Comment on it

    Implement Facebook Login/signup functionality by creating facebook sdk app.

    Followings are the steps to create facebook login/signup functionality on server end : 

    1) Login with facebook developers .

    2) Create an app , Put your domain link where you want to execute the facebook login and fill other options like email id, app name , app image etc.

    3) Make created app live by clicking "live" button  and copy down the app id to use it in our server.


    Following is the sample html snippet on clicking the facebook login pop up will be generated.

    <button type="button" class="connect-fb" onclick="fbLogin();" id="fb-login">Login With Facebook</button>

     

    Put the following script in your html file for facebook login

    <script type="text/javascript">
    
    window.fbAsyncInit = function() {
        FB.init({
            appId: '/* paste ur app id here .for eg. 542345324532 */', 
            status: true,
            cookie: true,
            xfbml: true,
            oauth: true
        });
    }
    
    function fbLogin() {
        
        FB.login(function(response) {
    
            if (response.authResponse) {
                FB.api('/me?fields=email,name', function(response) {
                    console.log(response);
                     var access_token =   FB.getAuthResponse()['accessToken'];
                        /*  You can use response variable for further use like storing in db for signup or login authentication etc. */
                });
            } else {
                console.log('User cancelled login or did not fully authorize.');
            }
        },
        {
            scope: 'public_profile,email'
        });
    }
    (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> 

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: