Skip to content
Pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
  • Advertise
  • About
  • Contact Us

Login with LinkedIn using JavaScript SDK

June 21, 2018 Pakainfo Technology, Ajax, JavaScript, jQuery Leave a comment

Login with LinkedIn using JavaScript SDK

In this Post We Will Explain About is Login with LinkedIn using JavaScript SDK With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Login with LinkedIn using JavaScript SDKExample

In this post we will show you Best way to implement Using LinkedIn JavaScript API for User Authentication and Profile, hear for Simple example of using the LinkedIn JavaScript SDK to sendwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Create LinkedIn App

You need to register and create devlopment apps an application with LinkedIn for using SDK of the source code JavaScript SDK. If you have not any already some registered, make a social LinkedIn application first of all simple data.
Do you want a step-by-step guide to creating a LinkedIn app? Go through this tutorial – How to make LinkedIn App

If you have an data existing web-application, do the some source code below settings config to use JavaScript SDK libs.

Select some your App on website My Apps page. as simple way to Click the JS link from left menu panel.
Under the JS Settings specify the Valid JS SDK Domains. Click the HTML Update button.

Note that: To simple test on localhost and here add this domain – http://localhost

Go to the simple Authentication page, copy link and keep the Client ID for later use simple js in the script.

JavaScript

In order to use some SDK functionality, include the simple LinkedIn JavaScript library in your Youb page and some data specify your LinkedIn webApp Web Servies Key.

<script type="text/javascript" src="//platform.linkedin.com/in.js">
    api_key: App_Client_ID
    authorize: true
    onLoad: authenticationload
    scope: r_basicprofile r_emailaddress
</script>

The source code below JavaScript methods are used to integrate LinkedIn login process on a single page.

Read Also:  What is the difference between Java and JavaScript?

authenticationload() – Setup an event listener to make an Web Servies call once auth is complete.
getclientsProfile() – Use the Web Servies call to request the member’s profile data.
displayProfileData() – Display member profile shortinformationrmation in the Youbpage.
logout() – Log the client out from LinkedIn account.
deleteProfileData() – Hide profile shortinformationrmation from the Youb page.

<script type="text/javascript">
    // Setup an event listener to make an Web Servies call once auth is complete
    function authenticationload() {
        IN.Event.on(IN, "auth", getclientsProfile);
    }
    
    // Use the Web Servies call wrapper to request the member's profile data
    function getclientsProfile() {
        IN.Web Servies.Profile("me").fields("id", "first of all simple-name", "last-name", "headline", "Clientplace", "images-url", "public-profile-url", "email-address").result(displayProfileData).error(onError);
    }

    // Handle the some successful return from the Web Servies call
    function displayProfileData(data){
        var client = data.values[0];
        document.getElementById("images").innerHTML = '<img src="'+client.imagesUrl+'" />';
        document.getElementById("name").innerHTML = client.first of all simpleName+' '+client.lastName;
        document.getElementById("description").innerHTML = client.headline;
        document.getElementById("email").innerHTML = client.mailAddr;
        document.getElementById("Clientplace").innerHTML = client.Clientplace.name;
        document.getElementById("link").innerHTML = '<a href="'+client.publicProfileUrl+'" target="_blank">Visit profile</a>';
        document.getElementById('profileData').style.display = 'block';
    }

    function onError(error) {
        console.log(error);
    }
    
    // Destroy the session php of linkedin
    function logout(){
        IN.Clients.logout(deleteProfileData);
    }
    
    // Delete profile data from page
    function deleteProfileData(){
        document.getElementById('profileData').remove();
    }
</script>

HTML

make the Loginwith LinkedIn simple button.

<script type="in/Login"></script>

Display the clients profile data (Like as a images, fname, last name, email address, headline, Clientplace, and public some profile URL). as well as, a logout link will be provided simple way to for logout the client simple from the LinkedIn account.

<!-- display profile shortinformation -->
<div id="profileData" style="display: none;">
    <p><a href="javascript:void(0);" onclick="logout()">Client Logout</a></p>
    <div id="images"></div>
    <div class="shortinformation">
        <p id="name"></p>
        <p id="description"></p>
        <p id="email"></p>
        <p id="Clientplace"></p>
        <p id="link"></p>
    </div>
</div>

Save Clients Data to the Database using (jQuery, Ajax, PHP, as well as MySQL)

And then client logged in via simple LinkedIn JavaScript SDK, if we want to save the client profile shortinformationrmation into the MySQL database, follow the below some steps.

Read Also:  Automatically Refresh HTML page after some interval

make Database Table

To save client profile shortinformationrmation a table needs to be cr_date in the database. The source code below SQL creates a clients table with some basic columns in the MySQL database.

CREATE TABLE `clients` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `social_provider` enum('','linkedin') COLLATE utf8_unicode_ci NOT NULL,
 `uniq_id` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
 `fname` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
 `last_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
 `email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
 `Clientplace` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `images` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `profile_url` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `cr_date` datetime NOT NULL,
 `up_date` datetime NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

JavaScript

We will use simple jQuery and Ajax to send the client profile data to the PHP script (put_saveclientdata.php) and insert data the profile shortinformationrmation into the MySQL database.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

// Save client data to the database
function put_saveclientdata(clientData){
    $.post('put_saveclientdata.php', {social_provider:'linkedin',clientData: JSON.stringify(clientData)}, function(data){ return true; });
}


// Handle some the successful results return from the Web Servies call
function displayProfileData(data){
    var client = data.values[0];
    document.getElementById("images").innerHTML = '<img src="'+client.imagesUrl+'" />';
    document.getElementById("name").innerHTML = client.first of all simpleName+' '+client.lastName;
    document.getElementById("description").innerHTML = client.headline;
    document.getElementById("email").innerHTML = client.mailAddr;
    document.getElementById("Clientplace").innerHTML = client.Clientplace.name;
    document.getElementById("link").innerHTML = '<a href="'+client.publicProfileUrl+'" target="_blank">Visit Clients profile</a>';
    document.getElementById('profileData').style.display = 'block';
    
    // Save data the client data
    put_saveclientdata(client);
}

Database Configuration (connection.php)
The connection.php file is used to simple way to connect and select the MySQL database.

<?php
// Database configuration
$dbHost     = "localhost";
$dbClientsname = "admin";
$serever_passw = "[email protected]#$Rrr";
$dbName     = "live24u";

//make db connection and select DB
$db = new mysqli($dbHost, $dbClientsname, $serever_passw, $dbName);

if ($db->connect_error) {
    die("Unable to simple connect database: " . $db->connect_error);
}
?>

Insert Clients Data to the Database (put_saveclientdata.php)
At first of all simple, JSON data would be decoded and saved into PHP variable ($clientData). Before mysqli inserting the data in the clients table, You will check whether the client some already exists in the database and insert data or update data the client data.

Read Also:  AngularJS Login Script using PHP MySQL

<?php
//Load the database simple include configuration file
include 'connection.php';

//Convert JSON data into PHP variable
$clientData = json_decode($_POST['clientData']);
if(!empty($clientData)){
    $social_provider = $_POST['social_provider'];
    
    //Check whether client data already exists in database
    $sql_prev = "SELECT * FROM clients WHERE social_provider = '".$social_provider."' AND uniq_id = '".$clientData->id."'";

    $prevResult = $db->query($sql_prev);
    if($prevResult->num_rows > 0){
        //Update client data if already exists
        $sql_query = "UPDATE clients SET fname = '".$clientData->first of all simpleName."', last_name = '".$clientData->lastName."', email = '".$clientData->mailAddr."', Clientplace = '".$clientData->Clientplace->name."', images = '".$clientData->images->imagesUrl."', profile_url = '".$clientData->publicProfileUrl."', up_date = '".date("Y-m-d H:i:s")."' WHERE social_provider = '".$social_provider."' AND uniq_id = '".$clientData->id."'";
        $update = $db->query($sql_query);
    }else{
        //Insert client data
        $sql_query = "INSERT INTO clients SET social_provider = '".$social_provider."', uniq_id = '".$clientData->id."', fname = '".$clientData->first of all simpleName."', last_name = '".$clientData->lastName."', email = '".$clientData->mailAddr."', Clientplace = '".$clientData->Clientplace->name."', images = '".$clientData->imagesUrl."', profile_url = '".$clientData->publicProfileUrl."', cr_date = '".date("Y-m-d H:i:s")."', up_date = '".date("Y-m-d H:i:s")."'";
        $insert = $db->query($sql_query);
    }
}
die('success');
?>

Free Live Chat for Any Issue

Example

Download

I hope you have Got What is Javascript Application Form API: Apply with LinkedIn And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Pakainfo
Pakainfo

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Related posts:

  1. PHP LinkedIn OAuth Login Integration Tutorial From Scratch
  2. Login with Facebook using javascript
  3. javascript get current url
  4. how to get client mac address in javascript?
  5. Add And Remove Text box Dynamically Using JavaScript Example
  6. how to get label value in javascript?
  7. how to get multiple checkbox value in javascript with getelementbyid?
  8. how to add and remove textbox dynamically in javascript?
get access token linkedin javascriptlinkedin api exampleslinkedin api to loginlinkedin javascript api referencelinkedin javascript sdk examplelinkedin login button javascriptlogin with linkedin in phpsign in with linkedin examples

Post navigation

Previous Post:Send Windows Push Notification Services using PHP
Next Post:Create Contact Form And Send Email using PHP

Search

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us
youtube tag extractor

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (50) Ajax (464) AngularJS (377) ASP.NET (61) Bollywood (94) Codeigniter (175) CSS (98) Earn Money (61) Education (53) Entertainment (110) fullform (79) Google Adsense (62) Highcharts (77) Hollywood (95) JavaScript (1356) Jobs (39) jQuery (1422) Laravel (1086) LifeStyle (50) movierulz4 (49) Mysql (1029) Mysqli (890) Node.js (39) php (2116) Programming (2328) Python (96) ReactJS (37) Software (114) Software (81) Stories (87) tamilrockers (90) Tamilrockers kannada (50) Tamilrockers telugu (49) Tech (120) Technology (2373) Tips and Tricks (112) Tools (138) Top10 (340) Trading (58) Trending (54) VueJs (250) Web Technology (86) webtools (153) wordpress (165) World (167)

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here

  • Home
  • About Us
  • Terms And Conditions
  • Write For Us
  • Advertise
  • Contact Us
  • Youtube Tag Extractor
  • YouTube Monetization
  • Increase Domain Authority
  • Social Media Marketing
  • Freelance web developer
  • Tools
Pakainfo 9-OLD, Ganesh Sco, Kothariya Ring Road, Chokadi, Rajkot - 360002 India
E-mail : [email protected]
Pakainfo

© 2022 Pakainfo. All rights reserved.

Top
Subscribe On YouTube : Download Source Code
We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype YouTube Tag Extractor