- md5
- 1228097f94f6a5fe87b12921ea01cbd4
- sha1
- a2f77dfdef189f02719dca18a0e6ce7464b864ce
- sha256
- 2d66028c91e8b68e4d9314e1940bb9cb1f3ac406900c792f09a63a23b6f2a1ac
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
<?php
/**
* @package Joomla.Platform
* @subpackage Linkedin
*
* @copyright Copyright (C) 2005 - 2017 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.
*
* @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;
}
}
The same content is in 34 releases, Joomla 3.7.0-alpha2 to 3.8.3. See them all, or every version of this file.