People like to login into any website using their social network accounts like Facebook, Twitter, Google, LinkedIn. It’s easy because user doesn’t have to fill lengthy forms, confirm their email address. Now many big websites support APIs for users to authenticate and login to any website. Now we are going to learn how users can Login to website using their LinkedIn.Com Account using PHP.
So now here is step by step tutorial on how to integrate login system with LinkedIn API using PHP.
Step 1:
We need to make new application on LinkedIn. Go to http://LinkedIn.com and Create a New Application.
Step 2:
Fill out the form to register a new application.
Step 3:
Application was created successfully. And copy API Key & Secret Key somewhere because it will be used in Application.
Step 4:
Download the code from above download button. Here is the folder structure for better understanding. We will edit only config.php for our login system to work.
images
| — linked-login.png //user login image
oAuth
| — class.linkedClass.php
| — config.php // change the API key, Secret key base URL &
| — linkedinoAuth.php
| — OAuth.php
authorize_success.php
example.php
linkedin.php
Step 5:
Edit Config.PHP and insert the API key and secret key that we obtained earlier from LinkedIn.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?php //linkedin configuration for Oauth $config['linkedin_access'] = 'api key'; $config['linkedin_secret'] = 'secret key'; $config['linkedin_library_path']= 'authorize_success.php'; $config['base_url'] = '/'; $config['callback_url'] = '/authorize_success.php'; ?> |
Change the base_url & callback_url as required.
Step 6:
Now run this demo script on your hosting and open example.php like this. http://yourdomain.com/linkedin/example.php.
This will show you similar page with button for user to click and login with LinkedIn.Com. Now when user clicks the login with LinkedIn button. It will take you to LinkedIn.Com website for authorization. See example below.
Step 7:
Click Allow Access button. It will redirect user back to authorize_success.php.
Step 8:
Now user access credentials can be saved in database for future use. And all information that LinkedIn sends back will be printed on the page by authorize_success.php.
Example screenshot below.
Check Demo:
Please check out demo to understand properly the sequence and working of script.
Hi,
I have SSL connection error .Please help me.