1
|
|
|
<?php namespace League\OAuth2\Client\Provider; |
2
|
|
|
|
3
|
|
|
use League\OAuth2\Client\Tool\ArrayAccessorTrait; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @property array $response |
7
|
|
|
* @property string $uid |
8
|
|
|
*/ |
9
|
|
|
class LinkedInResourceOwner extends GenericResourceOwner |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
use ArrayAccessorTrait; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Raw response |
16
|
|
|
* |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
protected $response; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Creates new resource owner. |
23
|
|
|
* |
24
|
|
|
* @param array $response |
25
|
|
|
*/ |
26
|
6 |
|
public function __construct(array $response = array()) |
27
|
|
|
{ |
28
|
6 |
|
$this->response = $response; |
29
|
6 |
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* A unique identifying value for the member. |
33
|
|
|
* |
34
|
|
|
* This value is linked to your specific application. |
35
|
|
|
* Any attempts to use it with a different application will |
36
|
|
|
* result in a "404 - Invalid member id" error. |
37
|
|
|
* |
38
|
|
|
* @return string|null |
39
|
|
|
*/ |
40
|
6 |
|
public function getId() |
41
|
|
|
{ |
42
|
6 |
|
return $this->getValueByKey($this->response, 'id'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* The member's first name. |
47
|
|
|
* |
48
|
|
|
* @return string|null |
49
|
|
|
*/ |
50
|
6 |
|
public function getFirstName() |
51
|
|
|
{ |
52
|
6 |
|
return $this->getValueByKey($this->response, 'firstName'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* The member's last name. |
57
|
|
|
* |
58
|
|
|
* @return string|null |
59
|
|
|
*/ |
60
|
6 |
|
public function getLastName() |
61
|
|
|
{ |
62
|
6 |
|
return $this->getValueByKey($this->response, 'lastName'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* The member's maiden name. |
67
|
|
|
* |
68
|
|
|
* @return string|null |
69
|
|
|
*/ |
70
|
|
|
public function getMaidenName() |
71
|
|
|
{ |
72
|
|
|
return $this->getValueByKey($this->response, 'maidenName'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* The member's name, formatted based on language. |
77
|
|
|
* |
78
|
|
|
* @return string|null |
79
|
|
|
*/ |
80
|
|
|
public function getFormattedName() |
81
|
|
|
{ |
82
|
|
|
return $this->getValueByKey($this->response, 'formattedName'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* The member's first name, spelled phonetically. |
87
|
|
|
* |
88
|
|
|
* @return string|null |
89
|
|
|
*/ |
90
|
|
|
public function getPhoneticFirstName() |
91
|
|
|
{ |
92
|
|
|
return $this->getValueByKey($this->response, 'phoneticFirstName'); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* The member's last name, spelled phonetically. |
97
|
|
|
* |
98
|
|
|
* @return string|null |
99
|
|
|
*/ |
100
|
|
|
public function getPhoneticLastName() |
101
|
|
|
{ |
102
|
|
|
return $this->getValueByKey($this->response, 'phoneticLastName'); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* The member's name, spelled phonetically and formatted based on language. |
107
|
|
|
* |
108
|
|
|
* @return string|null |
109
|
|
|
*/ |
110
|
|
|
public function getPhoneticFormattedName() |
111
|
|
|
{ |
112
|
|
|
return $this->getValueByKey($this->response, 'phoneticFormattedName'); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* The member's headline. |
117
|
|
|
* |
118
|
|
|
* @return string|null |
119
|
|
|
*/ |
120
|
6 |
|
public function getHeadline() |
121
|
|
|
{ |
122
|
6 |
|
return $this->getValueByKey($this->response, 'headline'); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* An object representing the user's physical location. |
127
|
|
|
* Available fields: name, country, country.code |
128
|
|
|
* Defaults to "name" for compatibility reasons |
129
|
|
|
* |
130
|
|
|
* @return string|array|null |
131
|
|
|
*/ |
132
|
6 |
|
public function getLocation($field = "name") |
133
|
|
|
{ |
134
|
6 |
|
if (is_null($field)) { |
135
|
|
|
return $this->getValueByKey($this->response, 'location'); |
136
|
|
|
} else { |
137
|
6 |
|
return $this->getValueByKey($this->response, 'location.' . $field); |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* The industry the member belongs to. |
143
|
|
|
* Available fields: name, country, country.code |
144
|
|
|
* |
145
|
|
|
* @return string|null |
146
|
|
|
*/ |
147
|
|
|
public function getIndustry() |
148
|
|
|
{ |
149
|
|
|
return $this->getValueByKey($this->response, 'industry'); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* The most recent item the member has shared on LinkedIn. |
154
|
|
|
* If the member has not shared anything, their 'status' is returned instead. |
155
|
|
|
* |
156
|
|
|
* @return string|null |
157
|
|
|
*/ |
158
|
|
|
public function getCurrentShare() |
159
|
|
|
{ |
160
|
|
|
return $this->getValueByKey($this->response, 'currentShare'); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* The number of LinkedIn connections the member has, capped at 500. |
165
|
|
|
* See 'num-connections-capped' to determine if the value returned has been capped. |
166
|
|
|
* |
167
|
|
|
* @return int|null |
168
|
|
|
*/ |
169
|
|
|
public function getNumConnections() |
170
|
|
|
{ |
171
|
|
|
return $this->getValueByKey($this->response, 'numConnections'); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Returns 'true' if the member's 'num-connections' value has been capped at 500', |
176
|
|
|
* or 'false' if 'num-connections' represents the user's true value.. |
177
|
|
|
* |
178
|
|
|
* @return bool|null |
179
|
|
|
*/ |
180
|
|
|
public function getNumConnectionsCapped() |
181
|
|
|
{ |
182
|
|
|
return $this->getValueByKey($this->response, 'numConnectionsCapped'); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* A long-form text area describing the member's professional profile. |
187
|
|
|
* |
188
|
|
|
* @return string|null |
189
|
|
|
*/ |
190
|
|
|
public function getSummary() |
191
|
|
|
{ |
192
|
|
|
return $this->getValueByKey($this->response, 'summary'); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* A short-form text area describing the member's specialties. |
197
|
|
|
* |
198
|
|
|
* @return string|null |
199
|
|
|
*/ |
200
|
|
|
public function getSpecialties() |
201
|
|
|
{ |
202
|
|
|
return $this->getValueByKey($this->response, 'specialties'); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* An object representing the member's current position. |
207
|
|
|
* |
208
|
|
|
* @return string|null |
209
|
|
|
*/ |
210
|
|
|
public function getPositions($field = null) |
211
|
|
|
{ |
212
|
|
|
if (is_null($field)) { |
213
|
|
|
return $this->getValueByKey($this->response, 'positions'); |
214
|
|
|
} else { |
215
|
|
|
return $this->getValueByKey($this->response, 'positions.' . $field); |
216
|
|
|
} |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* A URL to the member's formatted profile picture, if one has been provided. |
221
|
|
|
* |
222
|
|
|
* @return string|null |
223
|
|
|
*/ |
224
|
6 |
|
public function getPictureUrl() |
225
|
|
|
{ |
226
|
6 |
|
return $this->getValueByKey($this->response, 'pictureUrl'); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* A URL to the member's original unformatted profile picture. |
231
|
|
|
* This image is usually larger than the picture-url value above. |
232
|
|
|
* |
233
|
|
|
* @return string|null |
234
|
|
|
*/ |
235
|
|
|
public function getPictureUrls() |
236
|
|
|
{ |
237
|
|
|
return $this->getValueByKey($this->response, 'pictureUrls'); |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* The URL to the member's authenticated profile on LinkedIn. |
242
|
|
|
* You must be logged into LinkedIn to view this URL. |
243
|
|
|
* |
244
|
|
|
* @return string|array|null |
245
|
|
|
*/ |
246
|
|
|
public function getSiteStandardProfileRequest($field = 'url') |
247
|
|
|
{ |
248
|
|
|
if (is_null($field)) { |
249
|
|
|
return $this->getValueByKey($this->response, 'siteStandardProfileRequest'); |
250
|
|
|
} else { |
251
|
|
|
return $this->getValueByKey($this->response, 'siteStandardProfileRequest.' . $field); |
252
|
|
|
} |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* A URL representing the resource you would request for |
257
|
|
|
* programmatic access to the member's profile. |
258
|
|
|
* |
259
|
|
|
* @return string|null |
260
|
|
|
*/ |
261
|
|
|
public function getApiStandardProfileRequest() |
262
|
|
|
{ |
263
|
|
|
return $this->getValueByKey($this->response, 'apiStandardProfileRequest'); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* A URL representing the resource you would request for |
268
|
|
|
* programmatic access to the member's profile. |
269
|
|
|
* |
270
|
|
|
* @return string|null |
271
|
|
|
*/ |
272
|
6 |
|
public function getPublicProfileUrl() |
273
|
|
|
{ |
274
|
6 |
|
return $this->getValueByKey($this->response, 'publicProfileUrl'); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* The LinkedIn member's primary email address. |
279
|
|
|
* Secondary email addresses associated with the member |
280
|
|
|
* are not available via the API. |
281
|
|
|
* |
282
|
|
|
* @return string|null |
283
|
|
|
*/ |
284
|
6 |
|
public function getEmailAddress() |
285
|
|
|
{ |
286
|
6 |
|
return $this->getValueByKey($this->response, 'emailAddress'); |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
/** |
290
|
|
|
* Obsolete, left for compatibility reasons |
291
|
|
|
* Get user email |
292
|
|
|
* |
293
|
|
|
* @return string|null |
294
|
|
|
*/ |
295
|
6 |
|
public function getEmail() |
296
|
|
|
{ |
297
|
6 |
|
return $this->getEmailAddress(); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* Obsolete, left for compatibiliy reasons. |
302
|
|
|
* Get user imageurl |
303
|
|
|
* |
304
|
|
|
* @return string|null |
305
|
|
|
*/ |
306
|
6 |
|
public function getImageurl() |
307
|
|
|
{ |
308
|
6 |
|
return $this->getPictureUrl(); |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
|
312
|
|
|
/** |
313
|
|
|
* Obsolete, left for compatibility reasons. |
314
|
|
|
* Get user description |
315
|
|
|
* |
316
|
|
|
* @return string|null |
317
|
|
|
*/ |
318
|
6 |
|
public function getDescription() |
319
|
|
|
{ |
320
|
6 |
|
return $this->getHeadline(); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* Obsolete, left for compatibility reasons. |
325
|
|
|
* Get user url |
326
|
|
|
* |
327
|
|
|
* @return string|null |
328
|
|
|
*/ |
329
|
6 |
|
public function getUrl() |
330
|
|
|
{ |
331
|
6 |
|
return $this->getPublicProfileUrl(); |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* Return all of the owner details available as an array. |
336
|
|
|
* |
337
|
|
|
* @return array |
338
|
|
|
*/ |
339
|
6 |
|
public function toArray() |
340
|
|
|
{ |
341
|
6 |
|
return $this->response; |
342
|
|
|
} |
343
|
|
|
} |
344
|
|
|
|