1
- LinkedIn API Client with OAuth 2 authorization witten on PHP
1
+ LinkedIn API Client with OAuth 2 authorization written on PHP
2
2
============================================================
3
- [ ![ Build Status] ( https://travis-ci.org/zoonman/linkedin-client.svg )] ( https://travis-ci.org/zoonman/linkedin-client ) [ ![ Code Climate] ( https://codeclimate.com/github/zoonman/linkedin-client/badges/gpa.svg )] ( https://codeclimate.com/github/zoonman/linkedin-client ) [ ![ Packagist] ( https://img.shields.io/packagist/dt/zoonman/linkedin-client.svg )] ( https://packagist.org/packages/zoonman/linkedin-client ) [ ![ GitHub license] ( https://img.shields.io/github/license/zoonman/linkedin-client.svg )] ( https://github.com/zoonman/linkedin-client/LICENSE.md )
3
+ [ ![ Build Status] ( https://travis-ci.org/zoonman/linkedin-client.svg )] ( https://travis-ci.org/zoonman/linkedin-api-php- client ) [ ![ Code Climate] ( https://codeclimate.com/github/zoonman/linkedin-api-php- client/badges/gpa.svg )] ( https://codeclimate.com/github/zoonman/linkedin-api-php- client ) [ ![ Packagist] ( https://img.shields.io/packagist/dt/zoonman/linkedin-api-php- client.svg )] ( https://packagist.org/packages/zoonman/linkedin-api-php- client ) [ ![ GitHub license] ( https://img.shields.io/github/license/zoonman/linkedin-api-php- client.svg )] ( https://github.com/zoonman/linkedin-api-php -client/LICENSE.md )
4
4
5
5
6
6
@@ -49,23 +49,30 @@ $client = new Client(
49
49
50
50
#### Getting local redirect URL
51
51
52
- Get current redirect url use
52
+ To start linking process you have to setup redirect url.
53
+ You can set your own or use current one.
54
+ SDK provides you a ` getRedirectUrl() ` helper for your convenience:
53
55
54
56
``` php
55
- $client->getRedirectUrl();
57
+ $redirectUrl = $ client->getRedirectUrl();
56
58
```
57
59
60
+ We recommend you to have it stored during the linking session
61
+ because you will need to use it when you will be getting access token.
58
62
59
63
#### Setting local redirect URL
60
64
61
- To set redirect url use
65
+ Set a custom redirect url use:
62
66
63
67
``` php
64
68
$client->setRedirectUrl('http://your.domain.tld/path/to/script/');
65
69
```
66
70
67
71
#### Getting LinkedIn redirect URL
68
72
73
+ In order of performing OAUTH 2.0 flow, you should get LinkedIn login URL.
74
+ During this procedure you have to define scope of requested permissions.
75
+ Use ` Scope ` enum class to get scope names.
69
76
To get redirect url to LinkedIn, use the following approach:
70
77
71
78
``` php
@@ -76,9 +83,11 @@ $scopes = [
76
83
'rw_company_admin',
77
84
'w_share',
78
85
];
79
- $loginUrl = $client->getLoginUrl(); // get url on LinkedIn to start linking
86
+ $loginUrl = $client->getLoginUrl($scopes ); // get url on LinkedIn to start linking
80
87
```
81
88
89
+ Now you can take user to LinkedIn. You can use link or rely on Location HTTP header.
90
+
82
91
#### Getting Access Token
83
92
84
93
To get access token use (don't forget to set redirect url)
@@ -99,6 +108,17 @@ $profile = $client->api(
99
108
);
100
109
```
101
110
111
+ There are two helper methods:
112
+
113
+ ``` php
114
+ // get method
115
+ $client->get('ENDPOINT', ['param' => 'value']);
116
+
117
+ //post
118
+ $client->post('ENDPOINT', ['param' => 'value']);
119
+ ```
120
+
121
+
102
122
To perform api call to get profile information
103
123
104
124
``` php
@@ -108,31 +128,42 @@ $profile = $client->get(
108
128
print_r($profile);
109
129
```
110
130
111
- To list companies where you an admin
131
+ To list companies where you are an admin
112
132
113
133
``` php
114
134
$profile = $client->get(
115
- 'people/~:(id,email-address,first-name,last-name)'
135
+ 'companies',
136
+ ['is-company-admin' => true]
116
137
);
117
138
print_r($profile);
118
139
```
119
140
120
- To share content
141
+ To share content on a personal profile
121
142
122
143
``` php
123
144
$share = $client->post(
124
- 'people/~/shares',
125
- [
126
- 'comment' => 'Checkout this amazing PHP SDK for LinkedIn!',
127
- 'content' => [
128
- 'title' => 'PHP Client for LinkedIn API',
129
- 'description' => 'OAuth 2 flow, composer Package',
130
- 'submitted-url' => 'https://github.com/zoonman/linkedin-api-php-client',
131
- 'submitted-image-url' => 'https://github.com/fluidicon.png',
132
- ],
133
- 'visibility' => [
134
- 'code' => 'anyone'
135
- ]
136
- ]
137
- );
145
+ 'people/~/shares',
146
+ [
147
+ 'comment' => 'Checkout this amazing PHP SDK for LinkedIn!',
148
+ 'content' => [
149
+ 'title' => 'PHP Client for LinkedIn API',
150
+ 'description' => 'OAuth 2 flow, composer Package',
151
+ 'submitted-url' => 'https://github.com/zoonman/linkedin-api-php-client',
152
+ 'submitted-image-url' => 'https://github.com/fluidicon.png',
153
+ ],
154
+ 'visibility' => [
155
+ 'code' => 'anyone'
156
+ ]
157
+ ]
158
+ );
138
159
```
160
+
161
+
162
+ ## Contributing
163
+
164
+ Please, open PR with your changes linked to an GitHub issue.
165
+ You code must follow [ PSR] ( http://www.php-fig.org/psr/ ) standards and have PHPUnit tests.
166
+
167
+ ## License
168
+
169
+ [ MIT] ( LICENSE.md )
0 commit comments