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.
The source code below JavaScript methods are used to integrate LinkedIn login process on a single page.
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.
HTML
make the Loginwith LinkedIn simple button.
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.
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.
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.
// 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 = ''; 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 = 'Visit Clients profile'; 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.
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.
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'); ?>
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.