A PHP library to handle authentication and communication with LinkedIn API. The library/SDK helps you to get an access token and when authenticated it helps you to send API requests. You will not get everything for free though... You have to read the LinkedIn documentation to understand how you should query the API. We just help you with the boring stuff.
To get an overview what this library actually is doing for you. Take a look at the authentication page from the API docs.
Here is a list of features that might convince you to choose this LinkedIn client over some of our competitors'.
- Easy to extend
- Simple to implement
- Object oriented
- Using composer.json
- Handles CSRF protection for you
- Not developed for a specific framework.
- More than 85% test coverage.
- 580 lines of code, 540 lines of comments.
Install it with Composer!
// composer.json
{
// ...
require: {
// ...
"happyr/linkedin-api-client": "dev-master",
}
}
Then, you can install the new dependencies by running the composer update
command from the directory where your composer.json
file is located:
In order to use this API client (or any other LinkedIn clients) you have to register your application with LinkedIn to receive an API key. Once you've registered your LinkedIn app, you will be provided with an API Key and Secret Key.
This example below is a nicer way of connecting to LinkedIn compared to their code samples.
<?php
/**
* This demonstrates how to authenticate with LinkedIn and send api requests
*/
/*
* First you need to make sure you've used composers auto load. You have is probably
* already done this before. You usually don't bother..
*/
//require_once "vendor/autoload.php";
$linkedIn=new Happyr\LinkedIn\LinkedIn('app_id', 'app_secret');
if ($linkedIn->isAuthenticated()) {
//we know that the user is authenticated now. Start query the API
$user=$linkedIn->api('v1/people/~:(firstName,lastName)');
echo "Welcome ".$user['firstName'];
exit();
} elseif ($linkedIn->hasError()) {
echo "User canceled the login.";
exit();
}
//if not authenticated
$url = $linkedIn->getLoginUrl();
echo "<a href='$url'>Login with LinkedIn</a>";
See how I integrated this with Symfony2.