10 defined(
'JPATH_PLATFORM') or die();
36 public function getFriendIds($user, $cursor = null, $string_ids = null, $count = 0)
39 $this->checkRateLimit(
'friends',
'ids');
42 if (is_numeric($user))
44 $data[
'user_id'] = $user;
46 elseif (is_string($user))
48 $data[
'screen_name'] = $user;
53 throw new RuntimeException(
'The specified username is not in the correct format; must use integer or string');
57 if (!is_null($cursor))
59 $data[
'cursor'] = $cursor;
65 $data[
'stringify_ids'] = $string_ids;
71 $data[
'count'] = $count;
75 $path =
'/friends/ids.json';
78 return $this->sendRequest($path,
'GET', $data);
92 public function getFriendshipDetails($user_a, $user_b)
95 $this->checkRateLimit(
'friendships',
'show');
98 if (is_numeric($user_a))
100 $data[
'source_id'] = $user_a;
102 elseif (is_string($user_a))
104 $data[
'source_screen_name'] = $user_a;
109 throw new RuntimeException(
'The first specified username is not in the correct format; must use integer or string');
113 if (is_numeric($user_b))
115 $data[
'target_id'] = $user_b;
117 elseif (is_string($user_b))
119 $data[
'target_screen_name'] = $user_b;
124 throw new RuntimeException(
'The second specified username is not in the correct format; must use integer or string');
128 $path =
'/friendships/show.json';
131 return $this->sendRequest($path,
'GET', $data);
149 public function getFollowerIds($user, $cursor = null, $string_ids = null, $count = 0)
152 $this->checkRateLimit(
'followers',
'ids');
155 if (is_numeric($user))
157 $data[
'user_id'] = $user;
159 elseif (is_string($user))
161 $data[
'screen_name'] = $user;
166 throw new RuntimeException(
'The specified username is not in the correct format; must use integer or string');
170 $path =
'/followers/ids.json';
173 if (!is_null($cursor))
175 $data[
'cursor'] = $cursor;
179 if (!is_null($string_ids))
181 $data[
'stringify_ids'] = $string_ids;
185 if (!is_null($count))
187 $data[
'count'] = $count;
191 return $this->sendRequest($path,
'GET', $data);
206 public function getFriendshipsIncoming($cursor = null, $string_ids = null)
209 $this->checkRateLimit(
'friendships',
'incoming');
214 if (!is_null($cursor))
216 $data[
'cursor'] = $cursor;
220 if (!is_null($string_ids))
222 $data[
'stringify_ids'] = $string_ids;
226 $path =
'/friendships/incoming.json';
229 return $this->sendRequest($path,
'GET', $data);
244 public function getFriendshipsOutgoing($cursor = null, $string_ids = null)
247 $this->checkRateLimit(
'friendships',
'outgoing');
252 if (!is_null($cursor))
254 $data[
'cursor'] = $cursor;
258 if (!is_null($string_ids))
260 $data[
'stringify_ids'] = $string_ids;
264 $path =
'/friendships/outgoing.json';
267 return $this->sendRequest($path,
'GET', $data);
281 public function follow($user, $follow =
false)
284 if (is_numeric($user))
286 $data[
'user_id'] = $user;
288 elseif (is_string($user))
290 $data[
'screen_name'] = $user;
295 throw new RuntimeException(
'The specified username is not in the correct format; must use integer or string');
301 $data[
'follow'] = $follow;
305 $path =
'/friendships/create.json';
308 return $this->sendRequest($path,
'POST', $data);
321 public function unfollow($user)
324 if (is_numeric($user))
326 $data[
'user_id'] = $user;
328 elseif (is_string($user))
330 $data[
'screen_name'] = $user;
335 throw new RuntimeException(
'The specified username is not in the correct format; must use integer or string');
339 $path =
'/friendships/destroy.json';
342 return $this->sendRequest($path,
'POST', $data);
356 public function getFriendshipsLookup($screen_name = null, $id = null)
359 $this->checkRateLimit(
'friendships',
'lookup');
364 $data[
'user_id'] = $id;
368 $data[
'screen_name'] = $screen_name;
370 if ($id == null && $screen_name == null)
373 throw new RuntimeException(
'You must specify either a comma separated list of screen names, user IDs, or a combination of the two');
377 $path =
'/friendships/lookup.json';
380 return $this->sendRequest($path,
'GET', $data);
395 public function updateFriendship($user, $device = null, $retweets = null)
398 if (is_numeric($user))
400 $data[
'user_id'] = $user;
402 elseif (is_string($user))
404 $data[
'screen_name'] = $user;
409 throw new RuntimeException(
'The specified username is not in the correct format; must use integer or string');
413 if (!is_null($device))
415 $data[
'device'] = $device;
419 if (!is_null($retweets))
421 $data[
'retweets'] = $retweets;
425 $path =
'/friendships/update.json';
428 return $this->sendRequest($path,
'POST', $data);
440 public function getFriendshipNoRetweetIds($string_ids = null)
443 $this->checkRateLimit(
'friendships',
'no_retweets/ids');
448 if (!is_null($string_ids))
450 $data[
'stringify_ids'] = $string_ids;
454 $path =
'/friendships/no_retweets/ids.json';
457 return $this->sendRequest($path,
'GET', $data);