1
1
LinkedIn API Client with OAuth 2 authorization written on PHP
2
2
============================================================
3
- [ ![ Build Status] ( https://travis-ci.org/samoritano /linkedin-api-php-client.svg?branch=master )] ( https://travis-ci.org/samoritano /linkedin-api-php-client ) [ ![ Code Climate] ( https://codeclimate.com/github/samoritano /linkedin-api-php-client/badges/gpa.svg )] ( https://codeclimate.com/github/samoritano /linkedin-api-php-client ) [ ![ Packagist] ( https://img.shields.io/packagist/dt/samoritano /linkedin-api-php-client.svg )] ( https://packagist.org/packages/samoritano /linkedin-api-php-client-v2 ) [ ![ GitHub license] ( https://img.shields.io/github/license/samoritano /linkedin-api-php-client.svg )] ( https://github.com/samoritano /linkedin-api-php-client/blob/master/LICENSE.md )
3
+ [ ![ Build Status] ( https://travis-ci.org/AgencyPMG /linkedin-api-php-client.svg?branch=master )] ( https://travis-ci.org/AgencyPMG /linkedin-api-php-client ) [ ![ Code Climate] ( https://codeclimate.com/github/AgencyPMG /linkedin-api-php-client/badges/gpa.svg )] ( https://codeclimate.com/github/AgencyPMG /linkedin-api-php-client ) [ ![ Packagist] ( https://img.shields.io/packagist/dt/AgencyPMG /linkedin-api-php-client.svg )] ( https://packagist.org/packages/AgencyPMG /linkedin-api-php-client-v2 ) [ ![ GitHub license] ( https://img.shields.io/github/license/AgencyPMG /linkedin-api-php-client.svg )] ( https://github.com/AgencyPMG /linkedin-api-php-client/blob/master/LICENSE.md )
4
4
5
5
6
6
## Installation
@@ -10,7 +10,7 @@ You will need at least PHP 7.3. We match [officially supported](https://www.php.
10
10
Use [ composer] ( https://getcomposer.org/ ) package manager to install the lastest version of the package:
11
11
12
12
``` bash
13
- composer require samoritano /linkedin-api-php-client-v2
13
+ composer require pmg /linkedin-api-php-client
14
14
```
15
15
16
16
Or add this package as dependency to ` composer.json ` .
@@ -22,10 +22,10 @@ Or add this package as dependency to `composer.json`.
22
22
Before you will get started, play visit to [ LinkedIn API Documentation] ( https://docs.microsoft.com/en-us/linkedin/marketing/getting-started ) .
23
23
This will save you a lot of time and prevent some silly questions.
24
24
25
- To start working with LinkedIn API, you will need to
26
- get application client id and secret.
25
+ To start working with LinkedIn API, you will need to
26
+ get application client id and secret.
27
27
28
- Go to [ LinkedIn Developers portal] ( https://www.linkedin.com/developers/ )
28
+ Go to [ LinkedIn Developers portal] ( https://www.linkedin.com/developers/ )
29
29
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.
30
30
31
31
@@ -48,26 +48,26 @@ $client = new Client(
48
48
49
49
#### Getting local redirect URL
50
50
51
- To start linking process you have to setup redirect url.
51
+ To start linking process you have to setup redirect url.
52
52
You can set your own or use current one.
53
53
SDK provides you a ` getRedirectUrl() ` helper for your convenience:
54
54
55
55
``` php
56
56
$redirectUrl = $client->getRedirectUrl();
57
57
```
58
58
59
- We recommend you to have it stored during the linking session
59
+ We recommend you to have it stored during the linking session
60
60
because you will need to use it when you will be getting access token.
61
61
62
- #### Setting local redirect URL
62
+ #### Setting local redirect URL
63
63
64
64
Set a custom redirect url use:
65
65
66
66
``` php
67
67
$client->setRedirectUrl('http://your.domain.tld/path/to/script/');
68
68
```
69
69
70
- #### Getting LinkedIn redirect URL
70
+ #### Getting LinkedIn redirect URL
71
71
72
72
In order of performing OAUTH 2.0 flow, you should get LinkedIn login URL.
73
73
During this procedure you have to define scope of requested permissions.
@@ -82,7 +82,7 @@ use LinkedIn\Scope;
82
82
83
83
// define scope
84
84
$scopes = [
85
- Scope::READ_LITE_PROFILE,
85
+ Scope::READ_LITE_PROFILE,
86
86
Scope::READ_EMAIL_ADDRESS,
87
87
Scope::SHARE_AS_USER,
88
88
Scope::SHARE_AS_ORGANIZATION,
@@ -92,20 +92,20 @@ $loginUrl = $client->getLoginUrl($scopes); // get url on LinkedIn to start linki
92
92
93
93
Now you can take user to LinkedIn. You can use link or rely on Location HTTP header.
94
94
95
- #### Getting Access Token
95
+ #### Getting Access Token
96
96
97
97
To get access token use (don't forget to set redirect url)
98
98
99
99
``` php
100
100
$accessToken = $client->getAccessToken($_GET['code']);
101
101
```
102
- This method returns object of ` LinkedIn\AccessToken ` class.
102
+ This method returns object of ` LinkedIn\AccessToken ` class.
103
103
You can store this token in the file like this:
104
104
``` php
105
105
file_put_contents('token.json', json_encode($accessToken));
106
106
```
107
- This way of storing tokens is not recommended due to security concerns and used for demonstration purpose.
108
- Please, ensure that tokens are stored securely.
107
+ This way of storing tokens is not recommended due to security concerns and used for demonstration purpose.
108
+ Please, ensure that tokens are stored securely.
109
109
110
110
#### Setting Access Token
111
111
@@ -118,7 +118,7 @@ use LinkedIn\Client;
118
118
119
119
// instantiate the Linkedin client
120
120
$client = new Client(
121
- 'LINKEDIN_APP_CLIENT_ID',
121
+ 'LINKEDIN_APP_CLIENT_ID',
122
122
'LINKEDIN_APP_CLIENT_SECRET'
123
123
);
124
124
@@ -132,7 +132,7 @@ $accessToken = new AccessToken($tokenData['token'], $tokenData['expiresAt']);
132
132
$client->setAccessToken($accessToken);
133
133
```
134
134
135
- #### Performing API calls
135
+ #### Performing API calls
136
136
137
137
All API calls can be called through simple method:
138
138
@@ -211,25 +211,3 @@ Some private API access there.
211
211
``` php
212
212
$client->setApiRoot('https://api.linkedin.com/v2/');
213
213
```
214
-
215
- ##### ~ Image Upload~ --> OBSOLETE (This part needs an update)
216
-
217
- I assume you have to be LinkedIn partner or something like that.
218
-
219
- Try to upload image to LinkedIn. See [ Rich Media Shares] ( https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/rich-media-shares )
220
-
221
-
222
- ``` php
223
- $filename = '/path/to/image.jpg';
224
- $client->setApiRoot('https://api.linkedin.com/');
225
- $mp = $client->upload($filename);
226
- ```
227
-
228
- ## Contributing
229
-
230
- Please, open PR with your changes linked to an GitHub issue.
231
- You code must follow [ PSR] ( http://www.php-fig.org/psr/ ) standards and have PHPUnit tests.
232
-
233
- ## License
234
-
235
- [ MIT] ( LICENSE.md )
0 commit comments