Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Login with linkedin in php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 869
    Comment on it

    Follow the below steps in order to use the linkedin API.

    • Go to the Apps page at LinkedIn Developer Network and login with your LinkedIn account credentials https://www.linkedin.com/secure/developer

    • Click on the Add New Application link for create new App

    • Enter the new application details into the app registration form.

    After successfully registered you will get the linkedin API key and Secret Key .

    You have to download Twitter OAUTH library which can available very easily in Git hub. You will get below files ,

    • class.linkedClass.php // Class Get user Information
    • config.php // Configuration file
    • linkedinoAuth.php // Call methods
    • OAuth.php // Twitter OAUTH library

    Edit config.php

    <?php
    
    $config['base_url']             =   'http://demo.phpgang.com/'; 
    $config['callback_url']         =   'http://demo.phpgang.com/index.php';
    //linkedin configuration
    $config['linkedin_access']      =   'your_linkedin_access';
    $config['linkedin_secret']      =   'your_linkedin_secret'; 
    $config['linkedin_library_path']=   'linkedinoAuth.php';
    ?>
    

    Index.php

    Shows a button for linkedin authorization if not authorized.

    Redirect you to linkedin.php generate token and redirect to linkedin app authorization page.

    <?php
        session_start();
        include_once 'oAuth/config.php';
        include_once 'oAuth/linkedinoAuth.php';
    
        # First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
        $linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['base_url'] . 'linkedin_login_oauth/linkedinauth.php' );
    //    $linkedin->debug = true;
    
        # Now we retrieve a request token. It will be set as $linkedin->request_token
        $linkedin->getRequestToken();
        $_SESSION['requestToken'] = serialize($linkedin->request_token);
    
        # With a request token in hand, we can generate an authorization URL, which we'll direct the user to
       ## echo "Authorization URL: " . $linkedin->generateAuthorizeUrl() . "\n\n";
        header("Location: " . $linkedin->generateAuthorizeUrl());
    ?>
    

    Once you Allow access it will redirect you on linkedinauth.php (defined in linkedin.php) and show all data of authorized user.

 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: