PHPackages                             artisen2021/linkedinsdk - 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. [API Development](/categories/api)
4. /
5. artisen2021/linkedinsdk

ActiveLibrary[API Development](/categories/api)

artisen2021/linkedinsdk
=======================

Linkedin SDK for Wonderkind endpoints

v2.0.1(3y ago)05MITPHPPHP ^8.1

Since Aug 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Artisen2021/linkedinSDKEndpoints)[ Packagist](https://packagist.org/packages/artisen2021/linkedinsdk)[ RSS](/packages/artisen2021-linkedinsdk/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

LinkedIn SDK to setUp OAuth and manage campaign groups, campaigns, ads, ad targeting and social pages.
======================================================================================================

[](#linkedin-sdk-to-setup-oauth-and-manage-campaign-groups-campaigns-ads-ad-targeting-and-social-pages)

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

[](#installation)

You will need at least PHP 8.1.

Use composer package manager to install the lastest version of the package: `composer require artisen2021/linkedinsdk`

Or add this package as dependency to `composer.json`If you have never used Composer, you should start installing [composer](https://phptherightway.com/#composer_and_packagist).

Get started
-----------

[](#get-started)

Before starting, it's important to read LinkedIn API Documentation.

In section My Apps, create a new developer application related to your LinkedIn Page. Save the application `Client ID` and `Client Secret`. Generate an `access token`. Ensure you have the right permissions based on your use case. Apply to the Marketing Developer Platform.

### Instantiate a client

[](#instantiate-a-client)

```
$client = new Client(
'YOUR_LINKEDIN_APP_CLIENT_ID',
'YOUR_LINKEDIN_APP_CLIENT_SECRET'
);
```

### Setting local redirect URL

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

Set a custom redirect url. This url is called when the user is connected to LinkedIn and redirected to your application.

```
$this->linkedInClient->setRedirectUrl('https://your.domain/callback');
```

### Getting Login URL

[](#getting-login-url)

In order to perform OAUTH 2.0 flow, you must direct the member's browser to LinkedIn's OAuth 2.0 authorization page where the member connects to LinkedIn, then either accepts or denies your application's permission request. To get redirect url to LinkedIn, use the following approach:

```
$loginUrl = $client->getLoginUrl($scopes);
```

Once the user is connected and has completed the authorization process, the browser is redirected to the URL provided in the redirect\_uri query parameter and the Authorization Code appears in the URL. This code is a value that you exchange with LinkedIn for an OAuth 2.0 access token.

### Getting Access Token

[](#getting-access-token)

To get access token:

```
$this->token = (new AccessTokenRequest($this->linkedInClient))->getAccessToken($code)->getToken();
```

In the AccessTokenRequest class, this token is stored in a file token.json:

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

This AccessToken is used the header of the API calls.

```
$header = ['Authorization' => 'Bearer ' . $this->token];
```

Manage campaign groups
----------------------

[](#manage-campaign-groups)

### Create a campaign group

[](#create-a-campaign-group)

```
$campaignGroupRequest = new CampaignGroupRequest($this->linkedInClient, $this->accessTokenCode);
$campaignGroup =  $campaignGroupRequest->create([
     'account_id' => env('LINKEDIN_ACCOUNT_ID'),
     'name' => 'CampaignResources Group Test',
     'start' => 1672531200000,
     'end' => 1672617600000,
     'total_budget' => '100',
     'currency' => 'EUR'
]);
```

### Delete a campaign group

[](#delete-a-campaign-group)

```
$campaignGroupRequest = new CampaignGroupRequest($this->linkedInClient, $this->accessTokenCode);
$campaignGroupRequest->delete($campaignGroupId);
```

### Update a campaign group

[](#update-a-campaign-group)

```
$campaignGroupRequest = new CampaignGroupRequest($this->linkedInClient, $this->accessTokenCode);
$campaignGroupRequest->update($campaignGroupId, $this->newParams);
```

Manage campaigns
----------------

[](#manage-campaigns)

### Create a campaign

[](#create-a-campaign)

```
$campaignRequest = new CampaignRequest($this->linkedInClient, $this->accessTokenCode);
$campaign =  $campaignRequest->create([
      'account_id' => env('LINKEDIN_ACCOUNT_ID'),
      'campaign_group_id' => $campaignGroupId,
      'dailyBudget' => [
          'amount' => '20',
          'currencyCode' => 'EUR',
      ],
      'costType' => 'CPM',
      'country' => 'NL',
      'language' => 'nl',
      'name' => 'CampaignResources Test',
      'start' => 1672531200000,
      'end' => 1672617600000,
      'locations' => [
          "urn:li:geo:103644278"
      ],
      'type' => 'SPONSORED_UPDATES',
      'unitCost' => [
          'amount' => '30',
          'currencyCode' => 'EUR',
      ],
      'status' => 'ACTIVE'
]);
```

### Delete a campaign

[](#delete-a-campaign)

```
$campaignRequest = new CampaignRequest($this->linkedInClient, $this->accessTokenCode);
$campaignRequest->delete($campaignId);
```

### Update a campaign

[](#update-a-campaign)

```
$campaignRequest = new CampaignRequest($this->linkedInClient, $this->accessTokenCode);
$campaignRequest->update($campaignId, $this->newParams);
```

Manage ads
----------

[](#manage-ads)

### Create an add (image add)

[](#create-an-add-image-add)

```
        $adRequest = new AdRequest($this->linkedInClient, $this->accessTokenCode);
        $imageAd =  $adRequest->create([
            'account_id' => env('LINKEDIN_ACCOUNT_ID'),
            'linkedin_page_id' => env('LINKEDIN_PAGE_ID'),
            'campaign_id' => $campaignId,
            'media_type' => 'image',
            'message' => 'Image AdResources Test',
            'headline' => 'Image AdResources Test',
            'landing_page_url' => 'https://www.example.com/',
            'media_url' => 'https://www.example.com/image.jpg',
            'call_to_action' => 'attend',
        ]);
```

### Delete an add

[](#delete-an-add)

```
        $adRequest = new AdRequest($this->linkedInClient, $this->accessTokenCode);
        $adRequest->delete($adId);
```

### Update an add

[](#update-an-add)

```
        $adRequest = new AdRequest($this->linkedInClient, $this->accessTokenCode);
        $adRequest->update($adId, [
            'account_id' => env('LINKEDIN_ACCOUNT_ID'),
            'linkedin_page_id' => env('LINKEDIN_PAGE_ID'),
            'campaign_id' => $campaignId,
            'media_type' => 'image',
            'message' => 'Image AdResources Updated Test',
            'headline' => 'Image AdResources Updated Test',
            'landing_page_url' => 'https://www.example.com/',
            'media_url' => 'https://www.example2.com/image.jpg',
            'call_to_action' => 'attend'
        ]);
```

Manage ad targeting
-------------------

[](#manage-ad-targeting)

### Fetch location

[](#fetch-location)

```
$targetingRequest = new TargetingRequest($this->linkedInClient, $this->accessTokenCode);
$adFetched = $targetingRequest->fetchLocation($location);
```

### Fetch Urns

[](#fetch-urns)

```
$targetingRequest = new TargetingRequest($this->linkedInClient, $this->accessTokenCode);
$urns = $targetingRequest->fetchUrns($query,$facet);
```

### Fetch Similar

[](#fetch-similar)

```
$targetingRequest = new TargetingRequest($this->linkedInClient, $this->accessTokenCode);
$similars = $targetingRequest->fetchSimilar($urn,$facet);
```

Manage social pages
-------------------

[](#manage-social-pages)

### Get Pending Client Pages

[](#get-pending-client-pages)

```
        $pendingPagesEvent = new LinkedInRequestPendingPagesEvent(env('LINKEDIN_PAGE_ID'));
        $socialPages = new SocialPageRequest($this->linkedInClient, $this->accessTokenCode);
        $pendingPages = $socialPages->getPendingClientPages($pendingPagesEvent);
```

### Get Page Data

[](#get-page-data)

```
        $pageDataEvent = new LinkedInGetPageDataEvent(env('LINKEDIN_PAGE_ID'));
        $socialPages = new SocialPageRequest($this->linkedInClient, $this->accessTokenCode);
        $pageData = $socialPages->getPageData($pageDataEvent);
```

### Get Page Current Status

[](#get-page-current-status)

```
        $pageCurrentStatusEvent = new LinkedInGetPageCurrentStatusEvent(env('LINKEDIN_PAGE_ID'));
        $socialPages = new SocialPageRequest($this->linkedInClient, $this->accessTokenCode);
        $pageCurrentStatus = $socialPages->getPageCurrentStatus($pageCurrentStatusEvent);
```

### Search Ad Accounts By Page Id

[](#search-ad-accounts-by-page-id)

```
        $adAccountsEvent = new LinkedInRequestAdAccountsEvent(env('LINKEDIN_PAGE_ID'));
        $socialPages = new SocialPageRequest($this->linkedInClient, $this->accessTokenCode);
        $adAccounts = $socialPages->searchAdAccountsByPageId($adAccountsEvent);
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1408d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/619922d3af4b5257f389cc6e6bdd5c89d7e94012c58b1d4fa606eeab307bb764?d=identicon)[Artisen2021](/maintainers/Artisen2021)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/artisen2021-linkedinsdk/health.svg)

```
[![Health](https://phpackages.com/badges/artisen2021-linkedinsdk/health.svg)](https://phpackages.com/packages/artisen2021-linkedinsdk)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M733](/packages/sylius-sylius)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1943.1k5](/packages/aimeos-prisma)

PHPackages © 2026

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