Skip to content

Commit b43fc8f

Browse files
committed
doc: Update Readme
1 parent 67e7a19 commit b43fc8f

1 file changed

Lines changed: 21 additions & 77 deletions

File tree

Readme.md

Lines changed: 21 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# LinkedIn API client in PHP
22

3-
[![Latest Version](https://img.shields.io/github/release/Elninotech/Linkedin-API-client.svg?style=flat-square)](https://github.com/Elninotech/Linkedin-API-client/releases)
4-
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
5-
[![Build Status](https://img.shields.io/travis/Elninotech/Linkedin-API-client/master.svg?style=flat-square)](https://travis-ci.org/Elninotech/Linkedin-API-client)
6-
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/44c425af-90f6-4c25-b789-4ece28b01a2b/mini.png)](https://insight.sensiolabs.com/projects/44c425af-90f6-4c25-b789-4ece28b01a2b)
7-
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/Elninotech/Linkedin-API-client.svg?style=flat-square)](https://scrutinizer-ci.com/g/Elninotech/Linkedin-API-client)
8-
[![Quality Score](https://img.shields.io/scrutinizer/g/Elninotech/Linkedin-API-client.svg?style=flat-square)](https://scrutinizer-ci.com/g/Elninotech/Linkedin-API-client)
9-
[![Total Downloads](https://img.shields.io/packagist/dt/elninotech/linkedin-api-client.svg?style=flat-square)](https://packagist.org/packages/elninotech/linkedin-api-client)
3+
[![CI Status](https://github.com/elninotech/Linkedin-API-Client/workflows/CI/badge.svg)](https://github.com/elninotech/Linkedin-API-Client/actions)
4+
[![codecov](https://codecov.io/gh/elninotech/Linkedin-API-Client/branch/main/graph/badge.svg?token=0yzBUK8Wri)](https://codecov.io/gh/elninotech/Linkedin-API-Client)
5+
[![Latest Stable Version](https://poser.pugx.org/elninotech/linkedin-api-client/v)](https://packagist.org/packages/elninotech/linkedin-api-client)
6+
[![Total Downloads](https://poser.pugx.org/elninotech/linkedin-api-client/downloads)](https://packagist.org/packages/elninotech/linkedin-api-client/stats)
107

118

129
A PHP library to handle authentication and communication with LinkedIn API. The library/SDK helps you to get an access
@@ -56,24 +53,24 @@ Now you may install the library by running the following:
5653
composer require elninotech/linkedin-api-client
5754
```
5855

59-
If you are updating form a previous version make sure to read [the upgrade documentation](Upgrade.md).
56+
If you are updating from a previous version, make sure to read [the upgrade documentation](Upgrade.md).
6057

6158
### Finding the HTTP client (optional)
6259

63-
The LinkedIn client need to know what library you are using to send HTTP messages. You could provide an instance of
64-
HttpClient and MessageFactory or you could fallback on auto discovery. Below is an example on where you provide a Guzzle6
60+
The LinkedIn client needs to know what library you are using to send HTTP messages. You could provide an instance of
61+
HttpClient and MessageFactory or you could fall back to auto discovery. Below is an example of where you provide a Guzzle7
6562
instance.
6663

6764
```php
6865
$linkedIn=new Elnino\LinkedIn\LinkedIn('app_id', 'app_secret');
69-
$linkedIn->setHttpClient(new \Http\Adapter\Guzzle6\Client());
66+
$linkedIn->setHttpClient(new \Http\Adapter\Guzzle7\Client());
7067
$linkedIn->setHttpMessageFactory(new Http\Message\MessageFactory\GuzzleMessageFactory());
7168

7269
```
7370

7471
## Usage
7572

76-
In order to use this API client (or any other LinkedIn clients) you have to [register your application][register-app]
73+
In order to use this API client (or any other LinkedIn clients), you have to [register your application][register-app]
7774
with LinkedIn to receive an API key. Once you've registered your LinkedIn app, you will be provided with
7875
an *API Key* and *Secret Key*.
7976

@@ -98,7 +95,7 @@ $linkedIn=new Elnino\LinkedIn\LinkedIn('client_id', 'client_secret');
9895

9996
if ($linkedIn->isAuthenticated()) {
10097
//we know that the user is authenticated now. Start query the API
101-
$user=$linkedIn->get('v1/people/~:(firstName,lastName)');
98+
$user=$linkedIn->get('/v2/me/?projection=(id,firstName,lastName)');
10299
echo "Welcome ".$user['firstName'];
103100

104101
exit();
@@ -123,14 +120,14 @@ $linkedIn->setAccessToken('access_token_from_db');
123120

124121
$options = array('json'=>
125122
array(
126-
'comment' => 'Im testing Happyr LinkedIn client! https://github.com/Elninotech/Linkedin-API-client',
123+
'commentary' => 'Im testing the El Niño LinkedIn client! https://github.com/elninotech/Linkedin-API-client',
127124
'visibility' => array(
128125
'code' => 'anyone'
129126
)
130127
)
131128
);
132129

133-
$result = $linkedIn->post('v1/people/~/shares', $options);
130+
$result = $linkedIn->post('rest/posts', $options);
134131

135132
var_dump($result);
136133

@@ -141,18 +138,6 @@ var_dump($result);
141138

142139
```
143140

144-
You may of course do the same in xml. Use the following options array.
145-
```php
146-
$options = array(
147-
'format' => 'xml',
148-
'body' => '<share>
149-
<comment>Im testing Happyr LinkedIn client! https://github.com/Elninotech/Linkedin-API-client</comment>
150-
<visibility>
151-
<code>anyone</code>
152-
</visibility>
153-
</share>');
154-
```
155-
156141
## Configuration
157142

158143
### The api options
@@ -161,58 +146,26 @@ The third parameter of `LinkedIn::api` is an array with options. Below is a tabl
161146

162147
| Option name | Description
163148
| ----------- | -----------
164-
| body | The body of a HTTP request. Put your xml string here.
165-
| format | Set this to 'json', 'xml' or 'simple_xml' to override the default value.
149+
| body | The body of a HTTP request. Put your json string here.
166150
| headers | This is HTTP headers to the request
167-
| json | This is an array with json data that will be encoded to a json string. Using this option you do need to specify a format.
151+
| json | This is an array with json data that will be encoded to a json string.
168152
| response_data_type | To override the response format for one request
169153
| query | This is an array with query parameters
170154

171-
172-
173-
### Changing request format
174-
175-
The default format when communicating with LinkedIn API is json. You can let the API do `json_encode` for you.
176-
The following code shows you how.
177-
178-
```php
179-
$body = array(
180-
'comment' => 'Im testing Happyr LinkedIn client! https://github.com/Elninotech/Linkedin-API-client',
181-
'visibility' => array('code' => 'anyone')
182-
);
183-
184-
$linkedIn->post('v1/people/~/shares', array('json'=>$body));
185-
$linkedIn->post('v1/people/~/shares', array('body'=>json_encode($body)));
186-
```
187-
188-
When using `array('json'=>$body)` as option the format will always be `json`. You can change the request format in three ways.
189-
190-
```php
191-
// By constructor argument
192-
$linkedIn=new Elnino\LinkedIn\LinkedIn('app_id', 'app_secret', 'xml');
193-
194-
// By setter
195-
$linkedIn->setFormat('xml');
196-
197-
// Set format for just one request
198-
$linkedIn->post('v1/people/~/shares', array('format'=>'xml', 'body'=>$body));
199-
```
200-
201-
202155
### Understanding response data type
203156

204-
The data type returned from `LinkedIn::api` can be configured. You may use the forth construtor argument, the
157+
The data type returned from `LinkedIn::api` can be configured. You may use the third constructor argument, the
205158
`LinkedIn::setResponseDataType` or as an option for `LinkedIn::api`
206159

207160
```php
208161
// By constructor argument
209-
$linkedIn=new Elnino\LinkedIn\LinkedIn('app_id', 'app_secret', 'json', 'array');
162+
$linkedIn=new Elnino\LinkedIn\LinkedIn('app_id', 'app_secret', 'array');
210163

211164
// By setter
212165
$linkedIn->setResponseDataType('simple_xml');
213166

214167
// Set format for just one request
215-
$linkedIn->get('v1/people/~:(firstName,lastName)', array('response_data_type'=>'psr7'));
168+
$linkedIn->get('/v2/me/?projection=(id,firstName,lastName)', array('response_data_type'=>'psr7'));
216169

217170
```
218171

@@ -221,15 +174,14 @@ Below is a table that specifies what the possible return data types are when you
221174
| Type | Description
222175
| ------ | ------------
223176
| array | An assosiative array. This can only be used with the `json` format.
224-
| simple_xml | A SimpleXMLElement. See [PHP manual](http://php.net/manual/en/class.simplexmlelement.php). This can only be used with the `xml` format.
225177
| psr7 | A PSR7 response.
226178
| stream | A file stream.
227179
| string | A plain old string.
228180

229181

230182
### Use different Session classes
231183

232-
You might want to use an other storage than the default `SessionStorage`. If you are using Laravel
184+
You might want to use another storage than the default `SessionStorage`. If you are using Laravel
233185
you are more likely to inject the `IlluminateSessionStorage`.
234186
```php
235187
$linkedIn=new Elnino\LinkedIn\LinkedIn('app_id', 'app_secret');
@@ -252,15 +204,7 @@ $url = $linkedIn->getLoginUrl(array('scope'=>$scope));
252204
echo "<a href='$url'>Login with LinkedIn</a>";
253205
```
254206

255-
## Framework integration
256-
257-
If you want an easier integration with a framwork you may want to check out these repositories:
258-
259-
* [HappyrLinkedInBundle](https://github.com/Happyr/LinkedInBundle) for Symfony
260-
* [Laravel-Linkedin by mauri870](https://github.com/artesaos/laravel-linkedin) for Laravel 5
261-
262207

263-
[register-app]: https://www.linkedin.com/secure/developer
264-
[linkedin-code-samples]: https://developer.linkedin.com/documents/code-samples
265-
[api-doc-authentication]: https://developer.linkedin.com/documents/authentication
266-
[api-doc-core]: https://developer.linkedin.com/core-concepts
208+
[register-app]: https://www.linkedin.com/developers/apps
209+
[api-doc-authentication]: https://learn.microsoft.com/en-us/linkedin/shared/authentication/authentication
210+
[api-doc-core]: https://learn.microsoft.com/en-us/linkedin/shared/api-guide/concepts

0 commit comments

Comments
 (0)