LinkedIn API
<?php
require_once 'lib/LinkedIn/linkedin.php';
$linkedin = new LinkedIn(array(
'api_key' => 'xxxx',
'api_secret' => 'xxxx',
'callback_url' => 'xxxx'
));
$linkedin_login_url = $linkedin->getLoginUrl(
array(
LinkedIn::SCOPE_BASIC_PROFILE,
LinkedIn::SCOPE_EMAIL_ADDRESS,
LinkedIn::SCOPE_CONTACT_INFO
)
);
//on redirected page
$profile = array();
if(empty($_SESSION['linkedin_token'])){
$_SESSION['linkedin_token'] = $linkedin->getAccessToken($_REQUEST['code']);
}
$linkedin->setAccessToken($_SESSION['linkedin_token']);
$linkedin_profile = $linkedin->get('/people/~:(first-name,lastName,email-address,headline,positions:(title,company:(name,id)))');
$profile['firstname'] = $linkedin_profile['firstName'];
$profile['lastname'] = $linkedin_profile['lastName'];
if($linkedin_profile['positions']){
$profile['position'] = $linkedin_profile['positions']['values']['0']['title'];
$profile['company'] = $linkedin_profile['positions']['values']['0']['company']['name'];
}
$profile['name'] = $profile['firstname'].' '.$profile['lastname'];
$profile['email'] = $linkedin_profile['emailAddress'];