10 defined(
'JPATH_PLATFORM') or die();
35 public function inviteByEmail($email, $first_name, $last_name, $subject, $body, $connection =
'friend')
37 $token = $this->oauth->getToken();
41 'oauth_token' => $token[
'key']
45 $this->oauth->setOption(
'success_code', 201);
48 $base =
'/v1/people/~/mailbox';
51 $xml =
'<mailbox-item>
54 <person path="/people/email=' . $email .
'">
55 <first-name>' . $first_name .
'</first-name>
56 <last-name>' . $last_name .
'</last-name>
60 <subject>' . $subject .
'</subject>
61 <body>' . $body .
'</body>
64 <connect-type>' . $connection .
'</connect-type>
69 $header[
'Content-Type'] =
'text/xml';
72 $path = $this->getOption(
'api.url') . $base;
75 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);
94 public function inviteById($id, $first_name, $last_name, $subject, $body, $connection =
'friend')
96 $token = $this->oauth->getToken();
100 'oauth_token' => $token[
'key']
104 $base =
'/v1/people-search:(people:(api-standard-profile-request))';
106 $data[
'format'] =
'json';
107 $data[
'first-name'] = $first_name;
108 $data[
'last-name'] = $last_name;
111 $path = $this->getOption(
'api.url') . $base;
114 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
116 if (strpos($response->body,
'apiStandardProfileRequest') ===
false)
118 throw new RuntimeException($response->body);
122 $value = explode(
'"value": "', $response->body);
123 $value = explode(
'"', $value[1]);
127 $value = explode(
':', $value);
132 $this->oauth->setOption(
'success_code', 201);
135 $base =
'/v1/people/~/mailbox';
138 $xml =
'<mailbox-item>
141 <person path="/people/id=' . $id .
'">
145 <subject>' . $subject .
'</subject>
146 <body>' . $body .
'</body>
149 <connect-type>' . $connection .
'</connect-type>
151 <name>' . $name .
'</name>
152 <value>' . $value .
'</value>
154 </invitation-request>
158 $header[
'Content-Type'] =
'text/xml';
161 $path = $this->getOption(
'api.url') . $base;
164 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);
180 public function sendMessage($recipient, $subject, $body)
182 $token = $this->oauth->getToken();
186 'oauth_token' => $token[
'key']
190 $this->oauth->setOption(
'success_code', 201);
193 $base =
'/v1/people/~/mailbox';
196 $xml =
'<mailbox-item>
199 if (is_array($recipient))
201 foreach ($recipient as $r)
204 <person path="/people/' . $r .
'"/>
209 $xml .=
'</recipients>
210 <subject>' . $subject .
'</subject>
211 <body>' . $body .
'</body>
214 $header[
'Content-Type'] =
'text/xml';
217 $path = $this->getOption(
'api.url') . $base;
220 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);