10 defined(
'JPATH_PLATFORM') or die();
37 public function share($visibility, $comment = null, $title = null, $url = null, $image = null, $description = null, $twitter =
false)
39 $token = $this->oauth->getToken();
43 'oauth_token' => $token[
'key']
47 $this->oauth->setOption(
'success_code', 201);
50 $base =
'/v1/people/~/shares';
55 $base .=
'?twitter-post=true';
61 <code>' . $visibility .
'</code>
67 $xml .=
'<comment>' . $comment .
'</comment>';
74 <title>' . $title .
'</title>
75 <submitted-url>' . $url .
'</submitted-url>';
80 $xml .=
'<submitted-image-url>' . $image .
'</submitted-image-url>';
86 $xml .=
'<description>' . $description .
'</description>';
93 throw new RuntimeException(
'Post must contain comment and/or (title and url).');
99 $path = $this->getOption(
'api.url') . $base;
101 $header[
'Content-Type'] =
'text/xml';
104 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);
122 public function reshare($visibility, $id, $comment = null, $twitter =
false)
124 $token = $this->oauth->getToken();
128 'oauth_token' => $token[
'key']
132 $this->oauth->setOption(
'success_code', 201);
135 $base =
'/v1/people/~/shares';
140 $base .=
'?twitter-post=true';
146 <code>' . $visibility .
'</code>
152 $xml .=
'<comment>' . $comment .
'</comment>';
155 $xml .=
' <attribution>
163 $path = $this->getOption(
'api.url') . $base;
165 $header[
'Content-Type'] =
'text/xml';
168 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);
183 public function getCurrentShare($id = null, $url = null)
185 $token = $this->oauth->getToken();
189 'oauth_token' => $token[
'key']
193 $base =
'/v1/people/';
198 $base .=
'id=' . $id;
208 $base .=
'url=' . $this->oauth->safeEncode($url);
211 $base .=
':(current-share)';
214 $data[
'format'] =
'json';
217 $path = $this->getOption(
'api.url') . $base;
220 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
222 return json_decode($response->body);
236 public function getShareStream($id = null, $url = null, $self =
true)
238 $token = $this->oauth->getToken();
242 'oauth_token' => $token[
'key']
246 $base =
'/v1/people/';
261 $base .=
'url=' . $this->oauth->safeEncode($url);
267 $data[
'format'] =
'json';
268 $data[
'type'] =
'SHAR';
273 $data[
'scope'] =
'self';
277 $path = $this->getOption(
'api.url') . $base;
280 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
282 return json_decode($response->body);
302 public function getNetworkUpdates($id = null, $self =
true, $type = null, $count = 0, $start = 0, $after = null, $before = null,
305 $token = $this->oauth->getToken();
309 'oauth_token' => $token[
'key']
313 $base =
'/v1/people/';
325 $base .=
'/network/updates';
328 $data[
'format'] =
'json';
333 $data[
'scope'] =
'self';
339 $data[
'type'] = $type;
345 $data[
'count'] = $count;
351 $data[
'start'] = $start;
357 $data[
'after'] = $after;
363 $data[
'before'] = $before;
369 $data[
'hidden'] = $hidden;
373 $path = $this->getOption(
'api.url') . $base;
376 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
378 return json_decode($response->body);
388 public function getNetworkStats()
390 $token = $this->oauth->getToken();
394 'oauth_token' => $token[
'key']
398 $base =
'/v1/people/~/network/network-stats';
401 $data[
'format'] =
'json';
404 $path = $this->getOption(
'api.url') . $base;
407 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
409 return json_decode($response->body);
422 public function postNetworkUpdate($body)
424 $token = $this->oauth->getToken();
428 'oauth_token' => $token[
'key']
432 $this->oauth->setOption(
'success_code', 201);
435 $base =
'/v1/people/~/person-activities';
438 $xml =
'<activity locale="en_US">
439 <content-type>linkedin-html</content-type>
440 <body>' . $body .
'</body>
443 $header[
'Content-Type'] =
'text/xml';
446 $path = $this->getOption(
'api.url') . $base;
449 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);
463 public function getComments($key)
465 $token = $this->oauth->getToken();
469 'oauth_token' => $token[
'key']
473 $base =
'/v1/people/~/network/updates/key=' . $key .
'/update-comments';
476 $data[
'format'] =
'json';
479 $path = $this->getOption(
'api.url') . $base;
482 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
484 return json_decode($response->body);
497 public function postComment($key, $comment)
499 $token = $this->oauth->getToken();
503 'oauth_token' => $token[
'key']
507 $this->oauth->setOption(
'success_code', 201);
510 $base =
'/v1/people/~/network/updates/key=' . $key .
'/update-comments';
513 $xml =
'<update-comment>
514 <comment>' . $comment .
'</comment>
517 $header[
'Content-Type'] =
'text/xml';
520 $path = $this->getOption(
'api.url') . $base;
523 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);
537 public function getLikes($key)
539 $token = $this->oauth->getToken();
543 'oauth_token' => $token[
'key']
547 $base =
'/v1/people/~/network/updates/key=' . $key .
'/likes';
550 $data[
'format'] =
'json';
553 $path = $this->getOption(
'api.url') . $base;
556 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
558 return json_decode($response->body);
571 private function _likeUnlike($key, $like)
573 $token = $this->oauth->getToken();
577 'oauth_token' => $token[
'key']
581 $this->oauth->setOption(
'success_code', 204);
584 $base =
'/v1/people/~/network/updates/key=' . $key .
'/is-liked';
587 $xml =
'<is-liked>' . $this->booleanToString($like) .
'</is-liked>';
590 $path = $this->getOption(
'api.url') . $base;
592 $header[
'Content-Type'] =
'text/xml';
595 $response = $this->oauth->oauthRequest($path,
'PUT', $parameters, $xml, $header);
609 public function like($key)
611 return $this->_likeUnlike($key,
true);
623 public function unlike($key)
625 return $this->_likeUnlike($key,
false);