You've already forked joomla_test
first commit
This commit is contained in:
224
libraries/joomla/linkedin/communications.php
Normal file
224
libraries/joomla/linkedin/communications.php
Normal file
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Linkedin API Social Communications class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
* @since 13.1
|
||||
*/
|
||||
class JLinkedinCommunications extends JLinkedinObject
|
||||
{
|
||||
/**
|
||||
* Method used to invite people.
|
||||
*
|
||||
* @param string $email A string containing email of the recipient.
|
||||
* @param string $first_name A string containing frist name of the recipient.
|
||||
* @param string $last_name A string containing last name of the recipient.
|
||||
* @param string $subject The subject of the message that will be sent to the recipient
|
||||
* @param string $body A text of the message.
|
||||
* @param string $connection Only connecting as a 'friend' is supported presently.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function inviteByEmail($email, $first_name, $last_name, $subject, $body, $connection = 'friend')
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 201);
|
||||
|
||||
// Set the API base.
|
||||
$base = '/v1/people/~/mailbox';
|
||||
|
||||
// Build the xml.
|
||||
$xml = '<mailbox-item>
|
||||
<recipients>
|
||||
<recipient>
|
||||
<person path="/people/email=' . $email . '">
|
||||
<first-name>' . $first_name . '</first-name>
|
||||
<last-name>' . $last_name . '</last-name>
|
||||
</person>
|
||||
</recipient>
|
||||
</recipients>
|
||||
<subject>' . $subject . '</subject>
|
||||
<body>' . $body . '</body>
|
||||
<item-content>
|
||||
<invitation-request>
|
||||
<connect-type>' . $connection . '</connect-type>
|
||||
</invitation-request>
|
||||
</item-content>
|
||||
</mailbox-item>';
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to invite people.
|
||||
*
|
||||
* @param string $id Member id.
|
||||
* @param string $first_name A string containing frist name of the recipient.
|
||||
* @param string $last_name A string containing last name of the recipient.
|
||||
* @param string $subject The subject of the message that will be sent to the recipient
|
||||
* @param string $body A text of the message.
|
||||
* @param string $connection Only connecting as a 'friend' is supported presently.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function inviteById($id, $first_name, $last_name, $subject, $body, $connection = 'friend')
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base for people search.
|
||||
$base = '/v1/people-search:(people:(api-standard-profile-request))';
|
||||
|
||||
$data['format'] = 'json';
|
||||
$data['first-name'] = $first_name;
|
||||
$data['last-name'] = $last_name;
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
if (strpos($response->body, 'apiStandardProfileRequest') === false)
|
||||
{
|
||||
throw new RuntimeException($response->body);
|
||||
}
|
||||
|
||||
// Get header value.
|
||||
$value = explode('"value": "', $response->body);
|
||||
$value = explode('"', $value[1]);
|
||||
$value = $value[0];
|
||||
|
||||
// Split on the colon character.
|
||||
$value = explode(':', $value);
|
||||
$name = $value[0];
|
||||
$value = $value[1];
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 201);
|
||||
|
||||
// Set the API base.
|
||||
$base = '/v1/people/~/mailbox';
|
||||
|
||||
// Build the xml.
|
||||
$xml = '<mailbox-item>
|
||||
<recipients>
|
||||
<recipient>
|
||||
<person path="/people/id=' . $id . '">
|
||||
</person>
|
||||
</recipient>
|
||||
</recipients>
|
||||
<subject>' . $subject . '</subject>
|
||||
<body>' . $body . '</body>
|
||||
<item-content>
|
||||
<invitation-request>
|
||||
<connect-type>' . $connection . '</connect-type>
|
||||
<authorization>
|
||||
<name>' . $name . '</name>
|
||||
<value>' . $value . '</value>
|
||||
</authorization>
|
||||
</invitation-request>
|
||||
</item-content>
|
||||
</mailbox-item>';
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to send messages via LinkedIn between two or more individuals connected to the member sending the message..
|
||||
*
|
||||
* @param mixed $recipient A string containing the member id or an array of ids.
|
||||
* @param string $subject The subject of the message that will be sent to the recipient
|
||||
* @param string $body A text of the message.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function sendMessage($recipient, $subject, $body)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 201);
|
||||
|
||||
// Set the API base.
|
||||
$base = '/v1/people/~/mailbox';
|
||||
|
||||
// Build the xml.
|
||||
$xml = '<mailbox-item>
|
||||
<recipients>';
|
||||
|
||||
if (is_array($recipient))
|
||||
{
|
||||
foreach ($recipient as $r)
|
||||
{
|
||||
$xml .= '<recipient>
|
||||
<person path="/people/' . $r . '"/>
|
||||
</recipient>';
|
||||
}
|
||||
}
|
||||
|
||||
$xml .= '</recipients>
|
||||
<subject>' . $subject . '</subject>
|
||||
<body>' . $body . '</body>
|
||||
</mailbox-item>';
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
476
libraries/joomla/linkedin/companies.php
Normal file
476
libraries/joomla/linkedin/companies.php
Normal file
@ -0,0 +1,476 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Linkedin API Companies class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
* @since 13.1
|
||||
*/
|
||||
class JLinkedinCompanies extends JLinkedinObject
|
||||
{
|
||||
/**
|
||||
* Method to retrieve companies using a company ID, a universal name, or an email domain.
|
||||
*
|
||||
* @param integer $id The unique internal numeric company identifier.
|
||||
* @param string $name The unique string identifier for a company.
|
||||
* @param string $domain Company email domains.
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getCompanies($id = null, $name = null, $domain = null, $fields = null)
|
||||
{
|
||||
// At least one value is needed to retrieve data.
|
||||
if ($id == null && $name == null && $domain == null)
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('You must specify a company ID, a universal name, or an email domain.');
|
||||
}
|
||||
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/companies';
|
||||
|
||||
if ($id && $name)
|
||||
{
|
||||
$base .= '::(' . $id . ',universal-name=' . $name . ')';
|
||||
}
|
||||
elseif ($id)
|
||||
{
|
||||
$base .= '/' . $id;
|
||||
}
|
||||
elseif ($name)
|
||||
{
|
||||
$base .= '/universal-name=' . $name;
|
||||
}
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
|
||||
if ($domain)
|
||||
{
|
||||
$data['email-domain'] = $domain;
|
||||
}
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to read shares for a particular company .
|
||||
*
|
||||
* @param string $id The unique company identifier.
|
||||
* @param string $type Any valid Company Update Type from the table: https://developer.linkedin.com/reading-company-updates.
|
||||
* @param integer $count Maximum number of updates to return.
|
||||
* @param integer $start The offset by which to start Network Update pagination.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getUpdates($id, $type = null, $count = 0, $start = 0)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/companies/' . $id . '/updates';
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if type is specified.
|
||||
if ($type)
|
||||
{
|
||||
$data['event-type'] = $type;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if start is specified.
|
||||
if ($start > 0)
|
||||
{
|
||||
$data['start'] = $start;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to search across company pages.
|
||||
*
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
* @param string $keywords Members who have all the keywords anywhere in their profile.
|
||||
* @param boolean $hq Matching companies by the headquarters location. When this is set to "true" and a location facet is used,
|
||||
* this restricts returned companies to only those whose headquarters resides in the specified location.
|
||||
* @param string $facets Facet buckets to return, e.g. location.
|
||||
* @param array $facet Array of facet values to search over. Contains values for location, industry, network, company-size,
|
||||
* num-followers-range and fortune, in exactly this order, null must be specified for an element if no value.
|
||||
* @param integer $start Starting location within the result set for paginated returns.
|
||||
* @param integer $count The number of results returned.
|
||||
* @param string $sort Controls the search result order. There are four options: relevance, relationship,
|
||||
* followers and company-size.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function search($fields = null, $keywords = null, $hq = false, $facets = null, $facet = null, $start = 0, $count = 0, $sort = null)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/company-search';
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Check if keywords is specified.
|
||||
if ($keywords)
|
||||
{
|
||||
$data['keywords'] = $keywords;
|
||||
}
|
||||
|
||||
// Check if hq is true.
|
||||
if ($hq)
|
||||
{
|
||||
$data['hq-only'] = $hq;
|
||||
}
|
||||
|
||||
// Check if facets is specified.
|
||||
if ($facets)
|
||||
{
|
||||
$data['facets'] = $facets;
|
||||
}
|
||||
|
||||
// Check if facet is specified.
|
||||
if ($facet)
|
||||
{
|
||||
$data['facet'] = array();
|
||||
for ($i = 0; $i < count($facet); $i++)
|
||||
{
|
||||
if ($facet[$i])
|
||||
{
|
||||
if ($i == 0)
|
||||
{
|
||||
$data['facet'][] = 'location,' . $facet[$i];
|
||||
}
|
||||
if ($i == 1)
|
||||
{
|
||||
$data['facet'][] = 'industry,' . $facet[$i];
|
||||
}
|
||||
if ($i == 2)
|
||||
{
|
||||
$data['facet'][] = 'network,' . $facet[$i];
|
||||
}
|
||||
if ($i == 3)
|
||||
{
|
||||
$data['facet'][] = 'company-size,' . $facet[$i];
|
||||
}
|
||||
if ($i == 4)
|
||||
{
|
||||
$data['facet'][] = 'num-followers-range,' . $facet[$i];
|
||||
}
|
||||
if ($i == 5)
|
||||
{
|
||||
$data['facet'][] = 'fortune,' . $facet[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if start is specified.
|
||||
if ($start > 0)
|
||||
{
|
||||
$data['start'] = $start;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if sort is specified.
|
||||
if ($sort)
|
||||
{
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of companies the current member is following.
|
||||
*
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getFollowed($fields = null)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/following/companies';
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to follow a company.
|
||||
*
|
||||
* @param string $id The unique identifier for a company.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function follow($id)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 201);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/following/companies';
|
||||
|
||||
// Build xml.
|
||||
$xml = '<company><id>' . $id . '</id></company>';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unfollow a company.
|
||||
*
|
||||
* @param string $id The unique identifier for a company.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function unfollow($id)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 204);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/following/companies/id=' . $id;
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'DELETE', $parameters);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a collection of suggested companies for the current user.
|
||||
*
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
* @param integer $start Starting location within the result set for paginated returns.
|
||||
* @param integer $count The number of results returned.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getSuggested($fields = null, $start = 0, $count = 0)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/suggestions/to-follow/companies';
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Check if start is specified.
|
||||
if ($start > 0)
|
||||
{
|
||||
$data['start'] = $start;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a collection of suggested companies for the current user.
|
||||
*
|
||||
* @param string $id The unique identifier for a company.
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
* @param integer $start Starting location within the result set for paginated returns.
|
||||
* @param integer $count The number of results returned.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getProducts($id, $fields = null, $start = 0, $count = 0)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/companies/' . $id . '/products';
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Check if start is specified.
|
||||
if ($start > 0)
|
||||
{
|
||||
$data['start'] = $start;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
}
|
1098
libraries/joomla/linkedin/groups.php
Normal file
1098
libraries/joomla/linkedin/groups.php
Normal file
File diff suppressed because it is too large
Load Diff
1
libraries/joomla/linkedin/index.html
Normal file
1
libraries/joomla/linkedin/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
372
libraries/joomla/linkedin/jobs.php
Normal file
372
libraries/joomla/linkedin/jobs.php
Normal file
@ -0,0 +1,372 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Linkedin API Jobs class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
* @since 13.1
|
||||
*/
|
||||
class JLinkedinJobs extends JLinkedinObject
|
||||
{
|
||||
/**
|
||||
* Method to retrieve detailed information about a job.
|
||||
*
|
||||
* @param integer $id The unique identifier for a job.
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getJob($id, $fields = null)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/jobs/' . $id;
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of bookmarked jobs for the current member.
|
||||
*
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getBookmarked($fields = null)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/job-bookmarks';
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to bookmark a job to the current user's account.
|
||||
*
|
||||
* @param integer $id The unique identifier for a job.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function bookmark($id)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 201);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/job-bookmarks';
|
||||
|
||||
// Build xml.
|
||||
$xml = '<job-bookmark><job><id>' . $id . '</id></job></job-bookmark>';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a bookmark.
|
||||
*
|
||||
* @param integer $id The unique identifier for a job.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function deleteBookmark($id)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 204);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/job-bookmarks/' . $id;
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'DELETE', $parameters);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve job suggestions for the current user.
|
||||
*
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
* @param integer $start Starting location within the result set for paginated returns.
|
||||
* @param integer $count The number of results returned.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getSuggested($fields = null, $start = 0, $count = 0)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/suggestions/job-suggestions';
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Check if start is specified.
|
||||
if ($start > 0)
|
||||
{
|
||||
$data['start'] = $start;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to search across LinkedIn's job postings.
|
||||
*
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
* @param string $keywords Members who have all the keywords anywhere in their profile.
|
||||
* @param string $company_name Jobs with a matching company name.
|
||||
* @param string $job_title Matches jobs with the same job title.
|
||||
* @param string $country_code Matches members with a location in a specific country. Values are defined in by ISO 3166 standard.
|
||||
* Country codes must be in all lower case.
|
||||
* @param integer $postal_code Matches members centered around a Postal Code. Must be combined with the country-code parameter.
|
||||
* Not supported for all countries.
|
||||
* @param integer $distance Matches members within a distance from a central point. This is measured in miles.
|
||||
* @param string $facets Facet buckets to return, e.g. location.
|
||||
* @param array $facet Array of facet values to search over. Contains values for company, date-posted, location, job-function,
|
||||
* industry, and salary, in exactly this order, null must be specified for an element if no value.
|
||||
* @param integer $start Starting location within the result set for paginated returns.
|
||||
* @param integer $count The number of results returned.
|
||||
* @param string $sort Controls the search result order. There are four options: R (relationship), DA (date-posted-asc),
|
||||
* DD (date-posted-desc).
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function search($fields = null, $keywords = null, $company_name = null, $job_title = null, $country_code = null, $postal_code = null,
|
||||
$distance = null, $facets = null, $facet = null, $start = 0, $count = 0, $sort = null)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/job-search';
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Check if keywords is specified.
|
||||
if ($keywords)
|
||||
{
|
||||
$data['keywords'] = $keywords;
|
||||
}
|
||||
|
||||
// Check if company-name is specified.
|
||||
if ($company_name)
|
||||
{
|
||||
$data['company-name'] = $company_name;
|
||||
}
|
||||
|
||||
// Check if job-title is specified.
|
||||
if ($job_title)
|
||||
{
|
||||
$data['job-title'] = $job_title;
|
||||
}
|
||||
|
||||
// Check if country_code is specified.
|
||||
if ($country_code)
|
||||
{
|
||||
$data['country-code'] = $country_code;
|
||||
}
|
||||
|
||||
// Check if postal_code is specified.
|
||||
if ($postal_code)
|
||||
{
|
||||
$data['postal-code'] = $postal_code;
|
||||
}
|
||||
|
||||
// Check if distance is specified.
|
||||
if ($distance)
|
||||
{
|
||||
$data['distance'] = $distance;
|
||||
}
|
||||
|
||||
// Check if facets is specified.
|
||||
if ($facets)
|
||||
{
|
||||
$data['facets'] = $facets;
|
||||
}
|
||||
|
||||
// Check if facet is specified.
|
||||
if ($facet)
|
||||
{
|
||||
$data['facet'] = array();
|
||||
for ($i = 0; $i < count($facet); $i++)
|
||||
{
|
||||
if ($facet[$i])
|
||||
{
|
||||
if ($i == 0)
|
||||
{
|
||||
$data['facet'][] = 'company,' . $this->oauth->safeEncode($facet[$i]);
|
||||
}
|
||||
if ($i == 1)
|
||||
{
|
||||
$data['facet'][] = 'date-posted,' . $facet[$i];
|
||||
}
|
||||
if ($i == 2)
|
||||
{
|
||||
$data['facet'][] = 'location,' . $facet[$i];
|
||||
}
|
||||
if ($i == 3)
|
||||
{
|
||||
$data['facet'][] = 'job-function,' . $this->oauth->safeEncode($facet[$i]);
|
||||
}
|
||||
if ($i == 4)
|
||||
{
|
||||
$data['facet'][] = 'industry,' . $facet[$i];
|
||||
}
|
||||
if ($i == 5)
|
||||
{
|
||||
$data['facet'][] = 'salary,' . $facet[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if start is specified.
|
||||
if ($start > 0)
|
||||
{
|
||||
$data['start'] = $start;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if sort is specified.
|
||||
if ($sort)
|
||||
{
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
}
|
151
libraries/joomla/linkedin/linkedin.php
Normal file
151
libraries/joomla/linkedin/linkedin.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Joomla Platform class for interacting with a Linkedin API instance.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
* @since 13.1
|
||||
*/
|
||||
class JLinkedin
|
||||
{
|
||||
/**
|
||||
* @var JRegistry Options for the Linkedin object.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* @var JHttp The HTTP client object to use in sending HTTP requests.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var JLinkedinOAuth The OAuth client.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $oauth;
|
||||
|
||||
/**
|
||||
* @var JLinkedinPeople Linkedin API object for people.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $people;
|
||||
|
||||
/**
|
||||
* @var JLinkedinGroups Linkedin API object for groups.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $groups;
|
||||
|
||||
/**
|
||||
* @var JLinkedinCompanies Linkedin API object for companies.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $companies;
|
||||
|
||||
/**
|
||||
* @var JLinkedinJobs Linkedin API object for jobs.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $jobs;
|
||||
|
||||
/**
|
||||
* @var JLinkedinStream Linkedin API object for social stream.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $stream;
|
||||
|
||||
/**
|
||||
* @var JLinkedinCommunications Linkedin API object for communications.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $communications;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JLinkedinOauth $oauth OAuth object
|
||||
* @param JRegistry $options Linkedin options object.
|
||||
* @param JHttp $client The HTTP client object.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function __construct(JLinkedinOauth $oauth = null, JRegistry $options = null, JHttp $client = null)
|
||||
{
|
||||
$this->oauth = $oauth;
|
||||
$this->options = isset($options) ? $options : new JRegistry;
|
||||
$this->client = isset($client) ? $client : new JHttp($this->options);
|
||||
|
||||
// Setup the default API url if not already set.
|
||||
$this->options->def('api.url', 'https://api.linkedin.com');
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to lazily create API objects
|
||||
*
|
||||
* @param string $name Name of property to retrieve
|
||||
*
|
||||
* @return JLinkedinObject Linkedin API object (statuses, users, favorites, etc.).
|
||||
*
|
||||
* @since 13.1
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
$class = 'JLinkedin' . ucfirst($name);
|
||||
|
||||
if (class_exists($class))
|
||||
{
|
||||
if (false == isset($this->$name))
|
||||
{
|
||||
$this->$name = new $class($this->options, $this->client, $this->oauth);
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Argument %s produced an invalid class name: %s', $name, $class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option from the JLinkedin instance.
|
||||
*
|
||||
* @param string $key The name of the option to get.
|
||||
*
|
||||
* @return mixed The option value.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getOption($key)
|
||||
{
|
||||
return $this->options->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the Linkedin instance.
|
||||
*
|
||||
* @param string $key The name of the option to set.
|
||||
* @param mixed $value The option value to set.
|
||||
*
|
||||
* @return JLinkedin This object for method chaining.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function setOption($key, $value)
|
||||
{
|
||||
$this->options->set($key, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
144
libraries/joomla/linkedin/oauth.php
Normal file
144
libraries/joomla/linkedin/oauth.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Joomla Platform class for generating Linkedin API access token.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
class JLinkedinOauth extends JOAuth1Client
|
||||
{
|
||||
/**
|
||||
* @var JRegistry Options for the JLinkedinOauth object.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JRegistry $options JLinkedinOauth options object.
|
||||
* @param JHttp $client The HTTP client object.
|
||||
* @param JInput $input The input object
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function __construct(JRegistry $options = null, JHttp $client = null, JInput $input = null)
|
||||
{
|
||||
$this->options = isset($options) ? $options : new JRegistry;
|
||||
|
||||
$this->options->def('accessTokenURL', 'https://www.linkedin.com/uas/oauth/accessToken');
|
||||
$this->options->def('authenticateURL', 'https://www.linkedin.com/uas/oauth/authenticate');
|
||||
$this->options->def('authoriseURL', 'https://www.linkedin.com/uas/oauth/authorize');
|
||||
$this->options->def('requestTokenURL', 'https://www.linkedin.com/uas/oauth/requestToken');
|
||||
|
||||
// Call the JOauthV1aclient constructor to setup the object.
|
||||
parent::__construct($this->options, $client, $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to verify if the access token is valid by making a request to an API endpoint.
|
||||
*
|
||||
* @return boolean Returns true if the access token is valid and false otherwise.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function verifyCredentials()
|
||||
{
|
||||
$token = $this->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Set the API url.
|
||||
$path = 'https://api.linkedin.com/v1/people::(~)';
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
// Verify response
|
||||
if ($response->code == 200)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to validate a response.
|
||||
*
|
||||
* @param string $url The request URL.
|
||||
* @param JHttpResponse $response The response to validate.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 13.1
|
||||
* @throws DomainException
|
||||
*/
|
||||
public function validateResponse($url, $response)
|
||||
{
|
||||
if (!$code = $this->getOption('success_code'))
|
||||
{
|
||||
$code = 200;
|
||||
}
|
||||
|
||||
if (strpos($url, '::(~)') === false && $response->code != $code)
|
||||
{
|
||||
if ($error = json_decode($response->body))
|
||||
{
|
||||
throw new DomainException('Error code ' . $error->errorCode . ' received with message: ' . $error->message . '.');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new DomainException($response->body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to set permissions.
|
||||
*
|
||||
* @param mixed $scope String or an array of string containing permissions.
|
||||
*
|
||||
* @return JLinkedinOauth This object for method chaining
|
||||
*
|
||||
* @see https://developer.linkedin.com/documents/authentication
|
||||
* @since 13.1
|
||||
*/
|
||||
public function setScope($scope)
|
||||
{
|
||||
$this->setOption('scope', $scope);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the current scope
|
||||
*
|
||||
* @return string String or an array of string containing permissions.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getScope()
|
||||
{
|
||||
return $this->getOption('scope');
|
||||
}
|
||||
}
|
106
libraries/joomla/linkedin/object.php
Normal file
106
libraries/joomla/linkedin/object.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Linkedin API object class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
* @since 13.1
|
||||
*/
|
||||
abstract class JLinkedinObject
|
||||
{
|
||||
/**
|
||||
* @var JRegistry Options for the Linkedin object.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* @var JHttp The HTTP client object to use in sending HTTP requests.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var JLinkedinOAuth The OAuth client.
|
||||
* @since 13.1
|
||||
*/
|
||||
protected $oauth;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JRegistry $options Linkedin options object.
|
||||
* @param JHttp $client The HTTP client object.
|
||||
* @param JLinkedinOAuth $oauth The OAuth client.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function __construct(JRegistry $options = null, JHttp $client = null, JLinkedinOAuth $oauth = null)
|
||||
{
|
||||
$this->options = isset($options) ? $options : new JRegistry;
|
||||
$this->client = isset($client) ? $client : new JHttp($this->options);
|
||||
$this->oauth = $oauth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to convert boolean to string.
|
||||
*
|
||||
* @param boolean $bool The boolean value to convert.
|
||||
*
|
||||
* @return string String with the converted boolean.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function booleanToString($bool)
|
||||
{
|
||||
if ($bool)
|
||||
{
|
||||
return 'true';
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'false';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option from the JLinkedinObject instance.
|
||||
*
|
||||
* @param string $key The name of the option to get.
|
||||
*
|
||||
* @return mixed The option value.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getOption($key)
|
||||
{
|
||||
return $this->options->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the JLinkedinObject instance.
|
||||
*
|
||||
* @param string $key The name of the option to set.
|
||||
* @param mixed $value The option value to set.
|
||||
*
|
||||
* @return JLinkedinObject This object for method chaining.
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function setOption($key, $value)
|
||||
{
|
||||
$this->options->set($key, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
381
libraries/joomla/linkedin/people.php
Normal file
381
libraries/joomla/linkedin/people.php
Normal file
@ -0,0 +1,381 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Linkedin API People class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
* @since 13.1
|
||||
*/
|
||||
class JLinkedinPeople extends JLinkedinObject
|
||||
{
|
||||
/**
|
||||
* Method to get a member's profile.
|
||||
*
|
||||
* @param string $id Member id of the profile you want.
|
||||
* @param string $url The public profile URL.
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
* @param string $type Choosing public or standard profile.
|
||||
* @param string $language A comma separated list of locales ordered from highest to lowest preference.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getProfile($id = null, $url = null, $fields = null, $type = 'standard', $language = null)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/';
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if a member id is specified.
|
||||
if ($id)
|
||||
{
|
||||
$base .= 'id=' . $id;
|
||||
}
|
||||
elseif (!$url)
|
||||
{
|
||||
$base .= '~';
|
||||
}
|
||||
|
||||
// Check if profile url is specified.
|
||||
if ($url)
|
||||
{
|
||||
$base .= 'url=' . $this->oauth->safeEncode($url);
|
||||
|
||||
// Choose public profile
|
||||
if (!strcmp($type, 'public'))
|
||||
{
|
||||
$base .= ':public';
|
||||
}
|
||||
}
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Check if language is specified.
|
||||
$header = array();
|
||||
if ($language)
|
||||
{
|
||||
$header = array('Accept-Language' => $language);
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data, $header);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of connections for a user who has granted access to his/her account.
|
||||
*
|
||||
* @param string $fields Request fields beyond the default ones.
|
||||
* @param integer $start Starting location within the result set for paginated returns.
|
||||
* @param integer $count The number of results returned.
|
||||
* @param string $modified Values are updated or new.
|
||||
* @param string $modified_since Value as a Unix time stamp of milliseconds since epoch.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getConnections($fields = null, $start = 0, $count = 500, $modified = null, $modified_since = null)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/connections';
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Check if start is specified.
|
||||
if ($start > 0)
|
||||
{
|
||||
$data['start'] = $start;
|
||||
}
|
||||
// Check if count is specified.
|
||||
if ($count != 500)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if modified is specified.
|
||||
if ($modified)
|
||||
{
|
||||
$data['modified'] = $modified;
|
||||
}
|
||||
|
||||
// Check if modified_since is specified.
|
||||
if ($modified_since)
|
||||
{
|
||||
$data['modified-since'] = $modified_since;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get information about people.
|
||||
*
|
||||
* @param string $fields Request fields beyond the default ones. provide 'api-standard-profile-request'
|
||||
* field for out of network profiles.
|
||||
* @param string $keywords Members who have all the keywords anywhere in their profile.
|
||||
* @param string $first_name Members with a matching first name. Matches must be exact.
|
||||
* @param string $last_name Members with a matching last name. Matches must be exactly.
|
||||
* @param string $company_name Members who have a matching company name on their profile.
|
||||
* @param boolean $current_company A value of true matches members who currently work at the company specified in the company-name
|
||||
* parameter.
|
||||
* @param string $title Matches members with that title on their profile.
|
||||
* @param boolean $current_title A value of true matches members whose title is currently the one specified in the title-name parameter.
|
||||
* @param string $school_name Members who have a matching school name on their profile.
|
||||
* @param string $current_school A value of true matches members who currently attend the school specified in the school-name parameter.
|
||||
* @param string $country_code Matches members with a location in a specific country. Values are defined in by ISO 3166 standard.
|
||||
* Country codes must be in all lower case.
|
||||
* @param integer $postal_code Matches members centered around a Postal Code. Must be combined with the country-code parameter.
|
||||
* Not supported for all countries.
|
||||
* @param integer $distance Matches members within a distance from a central point. This is measured in miles.
|
||||
* @param string $facets Facet buckets to return, e.g. location.
|
||||
* @param array $facet Array of facet values to search over. Contains values for location, industry, network, language,
|
||||
* current-company, past-company and school, in exactly this order, null must be specified for an element if no value.
|
||||
* @param integer $start Starting location within the result set for paginated returns.
|
||||
* @param integer $count The number of results returned.
|
||||
* @param string $sort Controls the search result order. There are four options: connections, recommenders,
|
||||
* distance and relevance.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function search($fields = null, $keywords = null, $first_name = null, $last_name = null, $company_name = null,
|
||||
$current_company = null, $title = null, $current_title = null, $school_name = null, $current_school = null, $country_code = null,
|
||||
$postal_code = null, $distance = null, $facets = null, $facet = null, $start = 0, $count = 10, $sort = null)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people-search';
|
||||
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if fields is specified.
|
||||
if ($fields)
|
||||
{
|
||||
$base .= ':' . $fields;
|
||||
}
|
||||
|
||||
// Check if keywords is specified.
|
||||
if ($keywords)
|
||||
{
|
||||
$data['keywords'] = $keywords;
|
||||
}
|
||||
|
||||
// Check if first_name is specified.
|
||||
if ($first_name)
|
||||
{
|
||||
$data['first-name'] = $first_name;
|
||||
}
|
||||
|
||||
// Check if last_name is specified.
|
||||
if ($last_name)
|
||||
{
|
||||
$data['last-name'] = $last_name;
|
||||
}
|
||||
|
||||
// Check if company-name is specified.
|
||||
if ($company_name)
|
||||
{
|
||||
$data['company-name'] = $company_name;
|
||||
}
|
||||
|
||||
// Check if current_company is specified.
|
||||
if ($current_company)
|
||||
{
|
||||
$data['current-company'] = $current_company;
|
||||
}
|
||||
|
||||
// Check if title is specified.
|
||||
if ($title)
|
||||
{
|
||||
$data['title'] = $title;
|
||||
}
|
||||
|
||||
// Check if current_title is specified.
|
||||
if ($current_title)
|
||||
{
|
||||
$data['current-title'] = $current_title;
|
||||
}
|
||||
|
||||
// Check if school_name is specified.
|
||||
if ($school_name)
|
||||
{
|
||||
$data['school-name'] = $school_name;
|
||||
}
|
||||
|
||||
// Check if current_school is specified.
|
||||
if ($current_school)
|
||||
{
|
||||
$data['current-school'] = $current_school;
|
||||
}
|
||||
|
||||
// Check if country_code is specified.
|
||||
if ($country_code)
|
||||
{
|
||||
$data['country-code'] = $country_code;
|
||||
}
|
||||
|
||||
// Check if postal_code is specified.
|
||||
if ($postal_code)
|
||||
{
|
||||
$data['postal-code'] = $postal_code;
|
||||
}
|
||||
|
||||
// Check if distance is specified.
|
||||
if ($distance)
|
||||
{
|
||||
$data['distance'] = $distance;
|
||||
}
|
||||
|
||||
// Check if facets is specified.
|
||||
if ($facets)
|
||||
{
|
||||
$data['facets'] = $facets;
|
||||
}
|
||||
|
||||
// Check if facet is specified.
|
||||
if ($facet)
|
||||
{
|
||||
$data['facet'] = array();
|
||||
for ($i = 0; $i < count($facet); $i++)
|
||||
{
|
||||
if ($facet[$i])
|
||||
{
|
||||
if ($i == 0)
|
||||
{
|
||||
$data['facet'][] = 'location,' . $facet[$i];
|
||||
}
|
||||
if ($i == 1)
|
||||
{
|
||||
$data['facet'][] = 'industry,' . $facet[$i];
|
||||
}
|
||||
if ($i == 2)
|
||||
{
|
||||
$data['facet'][] = 'network,' . $facet[$i];
|
||||
}
|
||||
if ($i == 3)
|
||||
{
|
||||
$data['facet'][] = 'language,' . $facet[$i];
|
||||
}
|
||||
if ($i == 4)
|
||||
{
|
||||
$data['facet'][] = 'current-company,' . $facet[$i];
|
||||
}
|
||||
if ($i == 5)
|
||||
{
|
||||
$data['facet'][] = 'past-company,' . $facet[$i];
|
||||
}
|
||||
if ($i == 6)
|
||||
{
|
||||
$data['facet'][] = 'school,' . $facet[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if start is specified.
|
||||
if ($start > 0)
|
||||
{
|
||||
$data['start'] = $start;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count != 10)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if sort is specified.
|
||||
if ($sort)
|
||||
{
|
||||
$data['sort'] = $sort;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
if (strpos($fields, 'api-standard-profile-request') === false)
|
||||
{
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
// Get header name.
|
||||
$name = explode('"name": "', $response->body);
|
||||
$name = explode('"', $name[1]);
|
||||
$name = $name[0];
|
||||
|
||||
// Get header value.
|
||||
$value = explode('"value": "', $response->body);
|
||||
$value = explode('"', $value[1]);
|
||||
$value = $value[0];
|
||||
|
||||
// Get request url.
|
||||
$url = explode('"url": "', $response->body);
|
||||
$url = explode('"', $url[1]);
|
||||
$url = $url[0];
|
||||
|
||||
// Build header for out of network profile.
|
||||
$header[$name] = $value;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($url, 'GET', $parameters, $data, $header);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
}
|
627
libraries/joomla/linkedin/stream.php
Normal file
627
libraries/joomla/linkedin/stream.php
Normal file
@ -0,0 +1,627 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Linkedin API Social Stream class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Linkedin
|
||||
* @since 13.1
|
||||
*/
|
||||
class JLinkedinStream extends JLinkedinObject
|
||||
{
|
||||
/**
|
||||
* Method to add a new share. Note: post must contain comment and/or (title and url).
|
||||
*
|
||||
* @param string $visibility One of anyone: all members or connections-only: connections only.
|
||||
* @param string $comment Text of member's comment.
|
||||
* @param string $title Title of shared document.
|
||||
* @param string $url URL for shared content.
|
||||
* @param string $image URL for image of shared content.
|
||||
* @param string $description Description of shared content.
|
||||
* @param boolean $twitter True to have LinkedIn pass the status message along to a member's tethered Twitter account.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function share($visibility, $comment = null, $title = null, $url = null, $image = null, $description = null, $twitter = false)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 201);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/shares';
|
||||
|
||||
// Check if twitter is true.
|
||||
if ($twitter)
|
||||
{
|
||||
$base .= '?twitter-post=true';
|
||||
}
|
||||
|
||||
// Build xml.
|
||||
$xml = '<share>
|
||||
<visibility>
|
||||
<code>' . $visibility . '</code>
|
||||
</visibility>';
|
||||
|
||||
// Check if comment specified.
|
||||
if ($comment)
|
||||
{
|
||||
$xml .= '<comment>' . $comment . '</comment>';
|
||||
}
|
||||
|
||||
// Check if title and url are specified.
|
||||
if ($title && $url)
|
||||
{
|
||||
$xml .= '<content>
|
||||
<title>' . $title . '</title>
|
||||
<submitted-url>' . $url . '</submitted-url>';
|
||||
|
||||
// Check if image is specified.
|
||||
if ($image)
|
||||
{
|
||||
$xml .= '<submitted-image-url>' . $image . '</submitted-image-url>';
|
||||
}
|
||||
|
||||
// Check if descrption id specified.
|
||||
if ($description)
|
||||
{
|
||||
$xml .= '<description>' . $description . '</description>';
|
||||
}
|
||||
|
||||
$xml .= '</content>';
|
||||
}
|
||||
elseif (!$comment)
|
||||
{
|
||||
throw new RuntimeException('Post must contain comment and/or (title and url).');
|
||||
}
|
||||
|
||||
$xml .= '</share>';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to reshare an existing share.
|
||||
*
|
||||
* @param string $visibility One of anyone: all members or connections-only: connections only.
|
||||
* @param string $id The unique identifier for a share.
|
||||
* @param string $comment Text of member's comment.
|
||||
* @param boolean $twitter True to have LinkedIn pass the status message along to a member's tethered Twitter account.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function reshare($visibility, $id, $comment = null, $twitter = false)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 201);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/shares';
|
||||
|
||||
// Check if twitter is true.
|
||||
if ($twitter)
|
||||
{
|
||||
$base .= '?twitter-post=true';
|
||||
}
|
||||
|
||||
// Build xml.
|
||||
$xml = '<share>
|
||||
<visibility>
|
||||
<code>' . $visibility . '</code>
|
||||
</visibility>';
|
||||
|
||||
// Check if comment specified.
|
||||
if ($comment)
|
||||
{
|
||||
$xml .= '<comment>' . $comment . '</comment>';
|
||||
}
|
||||
|
||||
$xml .= ' <attribution>
|
||||
<share>
|
||||
<id>' . $id . '</id>
|
||||
</share>
|
||||
</attribution>
|
||||
</share>';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a particular member's current share.
|
||||
*
|
||||
* @param string $id Member id of the profile you want.
|
||||
* @param string $url The public profile URL.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getCurrentShare($id = null, $url = null)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/';
|
||||
|
||||
// Check if a member id is specified.
|
||||
if ($id)
|
||||
{
|
||||
$base .= 'id=' . $id;
|
||||
}
|
||||
elseif (!$url)
|
||||
{
|
||||
$base .= '~';
|
||||
}
|
||||
|
||||
// Check if profile url is specified.
|
||||
if ($url)
|
||||
{
|
||||
$base .= 'url=' . $this->oauth->safeEncode($url);
|
||||
}
|
||||
|
||||
$base .= ':(current-share)';
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a particular member's current share.
|
||||
*
|
||||
* @param string $id Member id of the profile you want.
|
||||
* @param string $url The public profile URL.
|
||||
* @param boolean $self Used to return member's feed. Omitted to return aggregated network feed.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getShareStream($id = null, $url = null, $self = true)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/';
|
||||
|
||||
// Check if a member id is specified.
|
||||
if ($id)
|
||||
{
|
||||
$base .= $id;
|
||||
}
|
||||
elseif (!$url)
|
||||
{
|
||||
$base .= '~';
|
||||
}
|
||||
|
||||
// Check if profile url is specified.
|
||||
if ($url)
|
||||
{
|
||||
$base .= 'url=' . $this->oauth->safeEncode($url);
|
||||
}
|
||||
|
||||
$base .= '/network';
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
$data['type'] = 'SHAR';
|
||||
|
||||
// Check if self is true
|
||||
if ($self)
|
||||
{
|
||||
$data['scope'] = 'self';
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the users network updates.
|
||||
*
|
||||
* @param string $id Member id.
|
||||
* @param boolean $self Used to return member's feed. Omitted to return aggregated network feed.
|
||||
* @param mixed $type String containing any valid Network Update Type from the table or an array of strings
|
||||
* to specify more than one Network Update type.
|
||||
* @param integer $count Number of updates to return, with a maximum of 250.
|
||||
* @param integer $start The offset by which to start Network Update pagination.
|
||||
* @param string $after Timestamp after which to retrieve updates.
|
||||
* @param string $before Timestamp before which to retrieve updates.
|
||||
* @param boolean $hidden Whether to display updates from people the member has chosen to "hide" from their update stream.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getNetworkUpdates($id = null, $self = true, $type = null, $count = 0, $start = 0, $after = null, $before = null,
|
||||
$hidden = false)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/';
|
||||
|
||||
// Check if a member id is specified.
|
||||
if ($id)
|
||||
{
|
||||
$base .= $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$base .= '~';
|
||||
}
|
||||
|
||||
$base .= '/network/updates';
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Check if self is true.
|
||||
if ($self)
|
||||
{
|
||||
$data['scope'] = 'self';
|
||||
}
|
||||
|
||||
// Check if type is specified.
|
||||
if ($type)
|
||||
{
|
||||
$data['type'] = $type;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if start is specified.
|
||||
if ($start > 0)
|
||||
{
|
||||
$data['start'] = $start;
|
||||
}
|
||||
|
||||
// Check if after is specified.
|
||||
if ($after)
|
||||
{
|
||||
$data['after'] = $after;
|
||||
}
|
||||
|
||||
// Check if before is specified.
|
||||
if ($before > 0)
|
||||
{
|
||||
$data['before'] = $before;
|
||||
}
|
||||
|
||||
// Check if hidden is true.
|
||||
if ($hidden)
|
||||
{
|
||||
$data['hidden'] = $hidden;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get information about the current member's network.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getNetworkStats()
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/network/network-stats';
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the users network updates.
|
||||
*
|
||||
* @param string $body The actual content of the update. You can use HTML to include links to the user name and the content the user
|
||||
* created. Other HTML tags are not supported. All body text should be HTML entity escaped and UTF-8 compliant.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function postNetworkUpdate($body)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 201);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/person-activities';
|
||||
|
||||
// Build the xml.
|
||||
$xml = '<activity locale="en_US">
|
||||
<content-type>linkedin-html</content-type>
|
||||
<body>' . $body . '</body>
|
||||
</activity>';
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve all comments for a given network update.
|
||||
*
|
||||
* @param string $key update/update-key representing an update.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getComments($key)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/network/updates/key=' . $key . '/update-comments';
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a new comment to an existing update.
|
||||
*
|
||||
* @param string $key update/update-key representing an update.
|
||||
* @param string $comment Maximum length of 700 characters
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function postComment($key, $comment)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 201);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/network/updates/key=' . $key . '/update-comments';
|
||||
|
||||
// Build the xml.
|
||||
$xml = '<update-comment>
|
||||
<comment>' . $comment . '</comment>
|
||||
</update-comment>';
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve the complete list of people who liked an update.
|
||||
*
|
||||
* @param string $key update/update-key representing an update.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function getLikes($key)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/network/updates/key=' . $key . '/likes';
|
||||
|
||||
// Set request parameters.
|
||||
$data['format'] = 'json';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to like or unlike an update.
|
||||
*
|
||||
* @param string $key Update/update-key representing an update.
|
||||
* @param boolean $like True to like update, false otherwise.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
private function _likeUnlike($key, $like)
|
||||
{
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array(
|
||||
'oauth_token' => $token['key']
|
||||
);
|
||||
|
||||
// Set the success response code.
|
||||
$this->oauth->setOption('success_code', 204);
|
||||
|
||||
// Set the API base
|
||||
$base = '/v1/people/~/network/updates/key=' . $key . '/is-liked';
|
||||
|
||||
// Build xml.
|
||||
$xml = '<is-liked>' . $this->booleanToString($like) . '</is-liked>';
|
||||
|
||||
// Build the request path.
|
||||
$path = $this->getOption('api.url') . $base;
|
||||
|
||||
$header['Content-Type'] = 'text/xml';
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to like an update.
|
||||
*
|
||||
* @param string $key Update/update-key representing an update.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function like($key)
|
||||
{
|
||||
return $this->_likeUnlike($key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to unlike an update.
|
||||
*
|
||||
* @param string $key Update/update-key representing an update.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 13.1
|
||||
*/
|
||||
public function unlike($key)
|
||||
{
|
||||
return $this->_likeUnlike($key, false);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user