10 defined(
'JPATH_PLATFORM') or die();
34 public function getCompanies($id = null, $name = null, $domain = null, $fields = null)
37 if ($id == null && $name == null && $domain == null)
40 throw new RuntimeException(
'You must specify a company ID, a universal name, or an email domain.');
43 $token = $this->oauth->getToken();
47 'oauth_token' => $token[
'key']
51 $base =
'/v1/companies';
55 $base .=
'::(' . $id .
',universal-name=' . $name .
')';
63 $base .=
'/universal-name=' . $name;
67 $data[
'format'] =
'json';
71 $data[
'email-domain'] = $domain;
77 $base .=
':' . $fields;
81 $path = $this->getOption(
'api.url') . $base;
84 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
86 return json_decode($response->body);
101 public function getUpdates($id, $type = null, $count = 0, $start = 0)
103 $token = $this->oauth->getToken();
107 'oauth_token' => $token[
'key']
111 $base =
'/v1/companies/' . $id .
'/updates';
114 $data[
'format'] =
'json';
119 $data[
'event-type'] = $type;
125 $data[
'count'] = $count;
131 $data[
'start'] = $start;
135 $path = $this->getOption(
'api.url') . $base;
138 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
140 return json_decode($response->body);
162 public function search($fields = null, $keywords = null, $hq =
false, $facets = null, $facet = null, $start = 0, $count = 0, $sort = null)
164 $token = $this->oauth->getToken();
168 'oauth_token' => $token[
'key']
172 $base =
'/v1/company-search';
174 $data[
'format'] =
'json';
179 $base .=
':' . $fields;
185 $data[
'keywords'] = $keywords;
191 $data[
'hq-only'] = $hq;
197 $data[
'facets'] = $facets;
203 $data[
'facet'] = array();
204 for ($i = 0; $i < count($facet); $i++)
210 $data[
'facet'][] =
'location,' . $facet[$i];
214 $data[
'facet'][] =
'industry,' . $facet[$i];
218 $data[
'facet'][] =
'network,' . $facet[$i];
222 $data[
'facet'][] =
'company-size,' . $facet[$i];
226 $data[
'facet'][] =
'num-followers-range,' . $facet[$i];
230 $data[
'facet'][] =
'fortune,' . $facet[$i];
239 $data[
'start'] = $start;
245 $data[
'count'] = $count;
251 $data[
'sort'] = $sort;
255 $path = $this->getOption(
'api.url') . $base;
258 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
260 return json_decode($response->body);
272 public function getFollowed($fields = null)
274 $token = $this->oauth->getToken();
278 'oauth_token' => $token[
'key']
282 $base =
'/v1/people/~/following/companies';
284 $data[
'format'] =
'json';
289 $base .=
':' . $fields;
293 $path = $this->getOption(
'api.url') . $base;
296 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
298 return json_decode($response->body);
310 public function follow($id)
312 $token = $this->oauth->getToken();
316 'oauth_token' => $token[
'key']
320 $this->oauth->setOption(
'success_code', 201);
323 $base =
'/v1/people/~/following/companies';
326 $xml =
'<company><id>' . $id .
'</id></company>';
329 $path = $this->getOption(
'api.url') . $base;
331 $header[
'Content-Type'] =
'text/xml';
334 $response = $this->oauth->oauthRequest($path,
'POST', $parameters, $xml, $header);
348 public function unfollow($id)
350 $token = $this->oauth->getToken();
354 'oauth_token' => $token[
'key']
358 $this->oauth->setOption(
'success_code', 204);
361 $base =
'/v1/people/~/following/companies/id=' . $id;
364 $path = $this->getOption(
'api.url') . $base;
367 $response = $this->oauth->oauthRequest($path,
'DELETE', $parameters);
383 public function getSuggested($fields = null, $start = 0, $count = 0)
385 $token = $this->oauth->getToken();
389 'oauth_token' => $token[
'key']
393 $base =
'/v1/people/~/suggestions/to-follow/companies';
395 $data[
'format'] =
'json';
400 $base .=
':' . $fields;
406 $data[
'start'] = $start;
412 $data[
'count'] = $count;
416 $path = $this->getOption(
'api.url') . $base;
419 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
421 return json_decode($response->body);
436 public function getProducts($id, $fields = null, $start = 0, $count = 0)
438 $token = $this->oauth->getToken();
442 'oauth_token' => $token[
'key']
446 $base =
'/v1/companies/' . $id .
'/products';
448 $data[
'format'] =
'json';
453 $base .=
':' . $fields;
459 $data[
'start'] = $start;
465 $data[
'count'] = $count;
469 $path = $this->getOption(
'api.url') . $base;
472 $response = $this->oauth->oauthRequest($path,
'GET', $parameters, $data);
474 return json_decode($response->body);