PHPackages                             matthewmee1/linkedin-api-php-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. matthewmee1/linkedin-api-php-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

matthewmee1/linkedin-api-php-client
===================================

LinkedIn API PHP SDK with OAuth 2.0 &amp; CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.

0.0.9(8y ago)031MITPHPPHP &gt;=5.6

Since Aug 24Pushed 8y agoCompare

[ Source](https://github.com/matthewmee1/linkedin-api-php-client)[ Packagist](https://packagist.org/packages/matthewmee1/linkedin-api-php-client)[ Docs](https://github.com/zoonman/linkedin-api-php-client)[ RSS](/packages/matthewmee1-linkedin-api-php-client/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (10)Used By (0)

LinkedIn API Client with OAuth 2 authorization written on PHP
=============================================================

[](#linkedin-api-client-with-oauth-2-authorization-written-on-php)

[![Build Status](https://camo.githubusercontent.com/710cd04d9366ec0bbfefb01c69c423e988cf87ca51d077e42ef6367f571f68e7/68747470733a2f2f7472617669732d63692e6f72672f7a6f6f6e6d616e2f6c696e6b6564696e2d6170692d7068702d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/zoonman/linkedin-api-php-client) [![Code Climate](https://camo.githubusercontent.com/31670f8f3f41a93fed43a5d3d5722adb0dbc2b8f6e10c3679d8dc9356614e4aa/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7a6f6f6e6d616e2f6c696e6b6564696e2d6170692d7068702d636c69656e742f6261646765732f6770612e737667)](https://codeclimate.com/github/zoonman/linkedin-api-php-client) [![Packagist](https://camo.githubusercontent.com/f34c06a531a5551a54a53634527a1a2c0d2f2cbd079f90f5869fb410dfb97740/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a6f6f6e6d616e2f6c696e6b6564696e2d6170692d7068702d636c69656e742e737667)](https://packagist.org/packages/zoonman/linkedin-api-php-client) [![GitHub license](https://camo.githubusercontent.com/e5c601aaec811fb7f7575f9d47809b59c87a9ead1aae825168bedc910be71880/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7a6f6f6e6d616e2f6c696e6b6564696e2d6170692d7068702d636c69656e742e737667)](https://github.com/zoonman/linkedin-api-php-client/blob/master/LICENSE.md)

See [complete example](examples/) inside [index.php](examples/index.php) to get started.

Installation
------------

[](#installation)

Use composer package manager

```
composer require zoonman/linkedin-api-php-client
```

Or add this package as dependency to `composer.json`.

If you have never used Composer, you should start [here](http://www.phptherightway.com/#composer_and_packagist)and install composer.

Usage
-----

[](#usage)

To start working with LinkedIn API, you will need to get application client id and secret.

Go to [LinkedIn Developers portal](https://developer.linkedin.com/)and create new application in section My Apps.

#### Bootstrapping autoloader and instantiating a client

[](#bootstrapping-autoloader-and-instantiating-a-client)

```
// ... please, add composer autoloader first
include_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

// import client class
use LinkedIn\Client;

// instantiate the Linkedin client
$client = new Client(
    'LINKEDIN_APP_CLIENT_ID',
    'LINKEDIN_APP_CLIENT_SECRET'
);
```

#### Getting local redirect URL

[](#getting-local-redirect-url)

To start linking process you have to setup redirect url. You can set your own or use current one. SDK provides you a `getRedirectUrl()` helper for your convenience:

```
$redirectUrl = $client->getRedirectUrl();
```

We recommend you to have it stored during the linking session because you will need to use it when you will be getting access token.

#### Setting local redirect URL

[](#setting-local-redirect-url)

Set a custom redirect url use:

```
$client->setRedirectUrl('http://your.domain.tld/path/to/script/');
```

#### Getting LinkedIn redirect URL

[](#getting-linkedin-redirect-url)

In order of performing OAUTH 2.0 flow, you should get LinkedIn login URL. During this procedure you have to define scope of requested permissions. Use `Scope` enum class to get scope names. To get redirect url to LinkedIn, use the following approach:

```
// define scope
$scopes = [
    'r_basicprofile',
    'r_emailaddress',
    'rw_company_admin',
    'w_share',
];
$loginUrl = $client->getLoginUrl($scopes); // get url on LinkedIn to start linking
```

Now you can take user to LinkedIn. You can use link or rely on Location HTTP header.

#### Getting Access Token

[](#getting-access-token)

To get access token use (don't forget to set redirect url)

```
$accessToken = $client->getAccessToken($_GET['code']);
```

This method returns object of `LinkedIn\AccessToken` class. You can store this token in the file like this:

```
file_put_contents('token.json', json_encode($accessToken));
```

This way of storing tokens is not recommended due to security concerns and used for demonstration purpose. Please, ensure that tokens are stored securely.

#### Setting Access Token

[](#setting-access-token)

You can use method `setAccessToken()` for the `LinkedIn\Client` class to set token stored as string. You have to pass instance of `LinkedIn\AccessToken` to this method.

```
use LinkedIn\AccessToken;
use LinkedIn\Client;

// instantiate the Linkedin client
$client = new Client(
    'LINKEDIN_APP_CLIENT_ID',
    'LINKEDIN_APP_CLIENT_SECRET'
);

// load token from the file
$tokenString = file_get_contents('token.json');
$tokenData = json_decode($tokenString, true);
// instantiate access token object from stored data
$accessToken = new AccessToken($tokenData['token'], $tokenData['expires_at']);

// set token for client
$client->setAccessToken($accessToken);
```

#### Performing API calls

[](#performing-api-calls)

All API calls can be called through simple method:

```
$profile = $client->api(
    'ENDPOINT',
    ['parameter name' => 'its value here'],
    'HTTP method like GET for example'
);
```

There are two helper methods:

```
// get method
$client->get('ENDPOINT', ['param' => 'value']);

//post
$client->post('ENDPOINT', ['param' => 'value']);
```

To perform api call to get profile information

```
$profile = $client->get(
    'people/~:(id,email-address,first-name,last-name)'
);
print_r($profile);
```

To list companies where you are an admin

```
$profile = $client->get(
    'companies',
    ['is-company-admin' => true]
);
print_r($profile);
```

To share content on a personal profile

```
$share = $client->post(
    'people/~/shares',
    [
        'comment' => 'Checkout this amazing PHP SDK for LinkedIn!',
        'content' => [
            'title' => 'PHP Client for LinkedIn API',
            'description' => 'OAuth 2 flow, composer Package',
            'submitted-url' => 'https://github.com/zoonman/linkedin-api-php-client',
            'submitted-image-url' => 'https://github.com/fluidicon.png',
        ],
        'visibility' => [
            'code' => 'anyone'
        ]
    ]
);
```

Contributing
------------

[](#contributing)

Please, open PR with your changes linked to an GitHub issue. You code must follow [PSR](http://www.php-fig.org/psr/) standards and have PHPUnit tests.

License
-------

[](#license)

[MIT](LICENSE.md)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Recently: every ~15 days

Total

9

Last Release

3117d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae27a039cafb7271929bf2a29dd1317cc13abf4fd3a8e6c75f39c3cc88c8c0c6?d=identicon)[matthewmee1](/maintainers/matthewmee1)

---

Top Contributors

[![zoonman](https://avatars.githubusercontent.com/u/576297?v=4)](https://github.com/zoonman "zoonman (26 commits)")[![iamsalnikov](https://avatars.githubusercontent.com/u/3082586?v=4)](https://github.com/iamsalnikov "iamsalnikov (5 commits)")[![matthewmee1](https://avatars.githubusercontent.com/u/32457836?v=4)](https://github.com/matthewmee1 "matthewmee1 (2 commits)")[![danieljpost](https://avatars.githubusercontent.com/u/464951?v=4)](https://github.com/danieljpost "danieljpost (1 commits)")

---

Tags

apiclientrestauthAuthenticationwrapperoauthoauth2authorizationplatformsocialoauth2-clientintegrationsocial networklinkedinLinkedIn Loginlinked inlinkedin-apiphp-linkedinlinkedin-clientlinkedin-signinlinkedin-sdklinkedin.comoauth2-authentication

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/matthewmee1-linkedin-api-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/matthewmee1-linkedin-api-php-client/health.svg)](https://phpackages.com/packages/matthewmee1-linkedin-api-php-client)
```

###  Alternatives

[zoonman/linkedin-api-php-client

LinkedIn API PHP SDK with OAuth 2.0 &amp; CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.

127704.0k](/packages/zoonman-linkedin-api-php-client)[ezralazuardy/heimdall

Painless OAuth 2.0 Server for CodeIgniter 4

454.2k](/packages/ezralazuardy-heimdall)[artesaos/laravel-linkedin

Linkedin API integration for Laravel and Lumen 5

5666.5k](/packages/artesaos-laravel-linkedin)[chillerlan/php-oauth

A fully transparent, framework agnostic PSR-18 OAuth client.

4210.4k2](/packages/chillerlan-php-oauth)[chervand/yii2-oauth2-server

OAuth 2.0 server for Yii 2.0 with MAC tokens support.

1524.2k1](/packages/chervand-yii2-oauth2-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
