Follow the below steps in order to use the linkedin API.
After successfully registered you will get the linkedin API key and Secret Key .
You have to download Twitter OAUTH library which can available very easily in Git hub. You will get below files ,
- class.linkedClass.php // Class Get
user Information
- config.php // Configuration file
- linkedinoAuth.php // Call methods
- OAuth.php // Twitter OAUTH library
Edit config.php
<?php
$config['base_url'] = 'http://demo.phpgang.com/';
$config['callback_url'] = 'http://demo.phpgang.com/index.php';
//linkedin configuration
$config['linkedin_access'] = 'your_linkedin_access';
$config['linkedin_secret'] = 'your_linkedin_secret';
$config['linkedin_library_path']= 'linkedinoAuth.php';
?>
Index.php
Shows a button for linkedin authorization if not authorized.
Redirect you to linkedin.php generate token and redirect to linkedin app authorization page.
<?php
session_start();
include_once 'oAuth/config.php';
include_once 'oAuth/linkedinoAuth.php';
# First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
$linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['base_url'] . 'linkedin_login_oauth/linkedinauth.php' );
// $linkedin->debug = true;
# Now we retrieve a request token. It will be set as $linkedin->request_token
$linkedin->getRequestToken();
$_SESSION['requestToken'] = serialize($linkedin->request_token);
# With a request token in hand, we can generate an authorization URL, which we'll direct the user to
## echo "Authorization URL: " . $linkedin->generateAuthorizeUrl() . "\n\n";
header("Location: " . $linkedin->generateAuthorizeUrl());
?>
Once you Allow access it will redirect you on linkedinauth.php (defined in linkedin.php) and show all data of authorized user.
0 Comment(s)