Linkedin API Examples in PHP to get connections,email address,profile and phone number

In this Article,I have explained how to use Linkedin API using PHP Script to get all the connections,Contacts,email address,profile and phone number of linkedin users.
LinkedIn API allows users to fetch the email addresses,phone number of their LinkedIn contacts to our site.

Get Profile Info:
LinkedIn API requires the following permissions to get Connections
Permissions :r_basicprofile,r_fullprofile
Description: Required to retrieve Basic profile(Name, photo, headline, and current positions)and Full profile including experience, education, skills, and recommendations.

Get Email Address:
LinkedIn API requires the following permissions to get Email Address
Permissions :r_emailaddress
Description: Required to retrieve Email Address.

Get Connections:
LinkedIn API requires the following permissions to get Connections
Permissions: r_network
Description: Required to retrieve 1st and 2nd degree connections

Steps To Integrate Linkedin API in your site


1. Download Linkedin API 3.2.0.zip file from http://code.google.com/p/simple-linkedinphp.

2.You need to apply for a LinkedIn Application Key here(https://www.linkedin.com/secure/developer)to get the required API key and Secret key.

3.Demo Application Key Details:

Company:Demo
Application Name:   Demo
API Key:jkbccri8fkjq
Secret Key:4NBTsJM5hTpCdFeA
OAuth User Token:d7b31d47-3c59-4eb1-8122-b1175dfa84a0
OAuth User Secret:42224c12-c8dd-4630-b2c5-bfb2560f1af1

4. Installing the Files

- Extract Zip file on Web Server.
- Download OAuth.php file from http://code.google.com/p/oauth.

5.Open Demo.php.

6.Insert your LinkedIn application key into the $API_CONFIG configuration array:

$API_CONFIG = array(
 'appKey'       => '',
 'appSecret'    => '',
 'callbackUrl'  => NULL 
);

7.Open Linkedin class file and insert below line into the _URL_REQUEST constant Variable:

const _URL_REQUEST  = 'https://api.linkedin.com/uas/oauth/requestToken?scope=r_basicprofile+r_emailaddress+r_network+r_fullprofile+r_contactinfo';

8.Open demo.php file and insert below line into the $response Variable:

$response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url,email-address,phone-numbers)');

9.Open demo.php in browser.

10.Done.

I hope it will help you to integrate Linkedin API  in your site.