PHPackages                             globules-io/linkedin-php-sdk - 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. globules-io/linkedin-php-sdk

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

globules-io/linkedin-php-sdk
============================

This package is an SDK for using LinkedIn V2 Marketing API. You can use it for managing Company Pages in this social network

0.1.4(4y ago)0311MITPHPPHP ^7.4 || ^8.0

Since Aug 24Pushed 4y agoCompare

[ Source](https://github.com/globules-io/linkedin-php-sdk)[ Packagist](https://packagist.org/packages/globules-io/linkedin-php-sdk)[ Docs](https://github.com/globules-io/linkedin-php-sdk)[ RSS](/packages/globules-io-linkedin-php-sdk/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (5)Versions (26)Used By (0)

LinkedIn PHP SDK
----------------

[](#linkedin-php-sdk)

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

[](#installation)

You will need at least PHP 7.4. Compatible with PHP 8.x

Use [composer](https://getcomposer.org/) package manager to install the lastest version of the package:

```
composer require globules-io/linkedin-php-sdk
```

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

Get Started
-----------

[](#get-started)

Before you will get started, play visit to [LinkedIn API Documentation](https://docs.microsoft.com/en-us/linkedin/marketing/getting-started). This will save you a lot of time and prevent some silly questions. To start working with LinkedIn API, you will need to get application client id and secret.

Go to [LinkedIn Developers portal](https://www.linkedin.com/developers/)and create new application in section My Apps. Once your app has been approved, you will get a ClientId and ClientSecret, that you will use later.

#### LinkedIn Restrictions

[](#linkedin-restrictions)

The scopes or permissions aren't available right away when you register an application with LinkedIn. When you first create your app in the developer portal, you only have access to the `w_member_social` scope. You can start developing but the token you obtain at this stage will have no refresh information. Then you need to request access to the `Marketing Developer Platform` which will give you 2 additionals scopes, `r_emailaddress`, `r_liteprofile`Once your request has been approved, you will get access to all the remaining scopes and your token will have refresh information.

#### 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(
    'YOUR_LINKEDIN_APP_CLIENT_ID',
    'YOUR_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.

You can read more about Linkedin Api scopes [here](https://docs.microsoft.com/en-us/linkedin/shared/references/migrations/default-scopes-migration).

Use `Scope` enum class to get scope names. To get redirect url to LinkedIn, use the following approach:

```
use LinkedIn\Scope;

// define scope
$scopes = [
  Scope::READ_LITE_PROFILE,
  Scope::READ_EMAIL_ADDRESS,
  Scope::SHARE_AS_USER,
  Scope::SHARE_AS_ORGANIZATION,
];
$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['expiresAt']);

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

#### Renewing Tokens

[](#renewing-tokens)

LinkedIn tokens expire after 60 days but you can renew your access token by using the refresh token. Tokens can be then refreshed for 365 days, after which the end-user must re-auth.

```
$client->renewTokenFromRefreshToken($refreshToken);
```

#### 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 3 helper methods:

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

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

// delete
$client->delete('ENDPOINT');
```

#### Examples

[](#examples)

##### Perform api call to get profile information

[](#perform-api-call-to-get-profile-information)

```
$profile = $client->get(
    'me',
    ['fields' => 'id,firstName,lastName']
);
print_r($profile);
```

##### List companies where you are an admin

[](#list-companies-where-you-are-an-admin)

```
$profile = $client->get(
    'organizationalEntityAcls',
    ['q' => 'roleAssignee']
);
print_r($profile);
```

##### Get Company page profile

[](#get-company-page-profile)

```
$companyId = '123'; // use id of the company where you are an admin
$companyInfo = $client->get('organizations/' . $companyId);
print_r($companyInfo);
```

##### Setup custom API request headers

[](#setup-custom-api-request-headers)

Change different headers sent to LinkedIn API.

```
$client->setApiHeaders([
  'Content-Type' => 'application/json',
  'x-li-format' => 'json',
  'X-Restli-Protocol-Version' => '2.0.0', // use protocol v2
  'x-li-src' => 'msdk' // set a src header to "msdk" to mimic a mobile SDK
]);
```

##### Change default API root

[](#change-default-api-root)

Some private API access there.

```
$client->setApiRoot('https://api.linkedin.com/v2/');
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 60.2% 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 ~70 days

Recently: every ~31 days

Total

25

Last Release

1502d ago

PHP version history (3 changes)0.0.1PHP &gt;=5.6

0.0.16PHP &gt;=7.3

0.0.22PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/55cbab94cd43b77c3a2674932be5f5041ec8b191a0f30fd5c7643a683e3b5435?d=identicon)[globules-io](/maintainers/globules-io)

---

Top Contributors

[![zoonman](https://avatars.githubusercontent.com/u/576297?v=4)](https://github.com/zoonman "zoonman (71 commits)")[![samoritano](https://avatars.githubusercontent.com/u/7482684?v=4)](https://github.com/samoritano "samoritano (12 commits)")[![globules-io](https://avatars.githubusercontent.com/u/13317159?v=4)](https://github.com/globules-io "globules-io (12 commits)")[![n-gibs](https://avatars.githubusercontent.com/u/26901936?v=4)](https://github.com/n-gibs "n-gibs (9 commits)")[![sarhugo](https://avatars.githubusercontent.com/u/974762?v=4)](https://github.com/sarhugo "sarhugo (6 commits)")[![iamsalnikov](https://avatars.githubusercontent.com/u/3082586?v=4)](https://github.com/iamsalnikov "iamsalnikov (5 commits)")[![danieljpost](https://avatars.githubusercontent.com/u/464951?v=4)](https://github.com/danieljpost "danieljpost (1 commits)")[![MattBred](https://avatars.githubusercontent.com/u/17261474?v=4)](https://github.com/MattBred "MattBred (1 commits)")[![saulmoralespa](https://avatars.githubusercontent.com/u/19959663?v=4)](https://github.com/saulmoralespa "saulmoralespa (1 commits)")

---

Tags

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

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/globules-io-linkedin-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/globules-io-linkedin-php-sdk/health.svg)](https://phpackages.com/packages/globules-io-linkedin-php-sdk)
```

###  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)
