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 = ' ' . $first_name . ' ' . $last_name . ' ' . $subject . ' ' . $body . ' ' . $connection . ' '; $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 = ' ' . $subject . ' ' . $body . ' ' . $connection . ' ' . $name . ' ' . $value . ' '; $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 = ' '; if (is_array($recipient)) { foreach ($recipient as $r) { $xml .= ' '; } } $xml .= ' ' . $subject . ' ' . $body . ' '; $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; } }