joomla/linkedin

Joomla Linkedin Package

1.3.0 2018-05-25 02:32 UTC

This package is auto-updated.

Last update: 2024-04-18 16:44:51 UTC


README

Deprecated

The joomla/linkedin package is deprecated with no further updates planned.

Using the LinkedIn Package

The LinkedIn package is designed to be a straightforward interface for working with LinkedIn. It is based on the REST API. You can find documentation on the API at http://developer.linkedin.com/rest.

Instantiating Linkedin

Instantiating Linkedin is easy:

use Joomla\Linkedin\Linkedin;

$linkedin = new Linkedin;

This creates a basic Linkedin object that can be used to access resources on linkedin.com, using an active access token.

Generating an access token can be done by instantiating OAuth.

Create a LinkedIn application at https://www.linkedin.com/secure/developer in order to request permissions. Instantiate OAuth, passing the Registry options needed. By default you have to set and send headers manually in your application, but if you want this to be done automatically you can set Registry option 'sendheaders' to true.

use Joomla\Linkedin\Linkedin;
use Joomla\Linkedin\OAuth;
use Joomla\Registry\Registry;

$options = new Registry;
$options->set('consumer_key', $consumer_key);
$options->set('consumer_secret', $consumer_secret);
$options->set('callback', $callback_url);
$options->set('sendheaders', true);
$oauth = new OAuth($options);

$linkedin = new Linkedin($oauth);

Now you can authenticate and request the user to authorise your application in order to get an access token, but if you already have an access token stored you can set it to the OAuth object and if it's still valid your application will use it.

// Set the stored access token.
$oauth->setToken($token);

$access_token = $oauth->authenticate();

When calling the authenticate() method, your stored access token will be used only if it's valid, a new one will be created if you don't have an access token or if the stored one is not valid. The method will return a valid access token that's going to be used.

Accessing the LinkedIn API's objects

The LinkedIn package covers almost all Resources of the REST API:

  • Communications object interacts with Communications resources.
  • Companies object interacts with Companies resources.
  • Groups object interacts with Groups resources.
  • Jobs object interacts with Jobs resources.
  • People object interacts with People and Connections resources.
  • Stream object interacts with Social Stream resources.

Once a Linkedin object has been created, it is simple to use it to access LinkedIn:

$people = $linkedin->people->getConnections();

This will retrieve a list of connections for a user who has granted access to his/her account.

A More Complete Example

Below is an example demonstrating more of the Linkedin package.

use Joomla\Linkedin\Linkedin;
use Joomla\Linkedin\OAuth;
use Joomla\Registry\Registry;

$app_id = "app_id";
$app_secret = "app_secret";
$my_url = 'http://localhost/linkedin_test.php';


$options = new Registry;
$options->set('consumer_key', $key);
$options->set('consumer_secret', $secret);
$options->set('callback', $my_url);
$options->set('sendheaders', true);

$oauth = new OAuth($options);
$oauth->authenticate();

$linkedin = new Linkedin($oauth);

$people = $linkedin->people;
$response = $people->getProfile();

More Information

The following resources contain more information:

Installation via Composer

Add "joomla/linkedin": "2.0.*@dev" to the require block in your composer.json and then run composer install.

{
	"require": {
		"joomla/linkedin": "2.0.*@dev"
	}
}

Alternatively, you can simply run the following from the command line:

composer require joomla/linkedin "2.0.*@dev"