You've already forked joomla_test
first commit
This commit is contained in:
162
libraries/joomla/twitter/block.php
Normal file
162
libraries/joomla/twitter/block.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Block class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterBlock extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get the user ids the authenticating user is blocking.
|
||||
*
|
||||
* @param boolean $stringify_ids Provide this option to have ids returned as strings instead.
|
||||
* @param integer $cursor Causes the list of IDs to be broken into pages of no more than 5000 IDs at a time. The number of IDs returned
|
||||
* is not guaranteed to be 5000 as suspended users are filtered out after connections are queried. If no cursor
|
||||
* is provided, a value of -1 will be assumed, which is the first "page."
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getBlocking($stringify_ids = null, $cursor = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('blocks', 'ids');
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if stringify_ids is specified
|
||||
if (!is_null($stringify_ids))
|
||||
{
|
||||
$data['stringify_ids'] = $stringify_ids;
|
||||
}
|
||||
|
||||
// Check if cursor is specified
|
||||
if (!is_null($stringify_ids))
|
||||
{
|
||||
$data['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/blocks/ids.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to block the specified user from following the authenticating user.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
|
||||
* variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function block($user, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('blocks', 'create');
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_statuses is specified
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/blocks/create.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unblock the specified user from following the authenticating user.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
|
||||
* variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function unblock($user, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('blocks', 'destroy');
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_statuses is specified
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/blocks/destroy.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
}
|
220
libraries/joomla/twitter/directmessages.php
Normal file
220
libraries/joomla/twitter/directmessages.php
Normal file
@ -0,0 +1,220 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Direct Messages class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterDirectmessages extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get the most recent direct messages sent to the authenticating user.
|
||||
*
|
||||
* @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
||||
* @param integer $max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
||||
* @param integer $count Specifies the number of direct messages to try and retrieve, up to a maximum of 200.
|
||||
* @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety of metadata
|
||||
* about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getDirectMessages($since_id = 0, $max_id = 0, $count = 20, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('direct_messages');
|
||||
|
||||
// Set the API path
|
||||
$path = '/direct_messages.json';
|
||||
|
||||
// Check if since_id is specified.
|
||||
if ($since_id)
|
||||
{
|
||||
$data['since_id'] = $since_id;
|
||||
}
|
||||
|
||||
// Check if max_id is specified.
|
||||
if ($max_id)
|
||||
{
|
||||
$data['max_id'] = $max_id;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified.
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the most recent direct messages sent by the authenticating user.
|
||||
*
|
||||
* @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
||||
* @param integer $max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
||||
* @param integer $count Specifies the number of direct messages to try and retrieve, up to a maximum of 200.
|
||||
* @param integer $page Specifies the page of results to retrieve.
|
||||
* @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety of metadata
|
||||
* about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getSentDirectMessages($since_id = 0, $max_id = 0, $count = 20, $page = 0, $entities = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('direct_messages', 'sent');
|
||||
|
||||
// Set the API path
|
||||
$path = '/direct_messages/sent.json';
|
||||
|
||||
// Check if since_id is specified.
|
||||
if ($since_id)
|
||||
{
|
||||
$data['since_id'] = $since_id;
|
||||
}
|
||||
|
||||
// Check if max_id is specified.
|
||||
if ($max_id)
|
||||
{
|
||||
$data['max_id'] = $max_id;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if page is specified.
|
||||
if ($page)
|
||||
{
|
||||
$data['page'] = $page;
|
||||
}
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to send a new direct message to the specified user from the authenticating user.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param string $text The text of your direct message. Be sure to keep the message under 140 characters.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function sendDirectMessages($user, $text)
|
||||
{
|
||||
// Set the API path
|
||||
$path = '/direct_messages/new.json';
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
$data['text'] = $text;
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a single direct message, specified by an id parameter.
|
||||
*
|
||||
* @param integer $id The ID of the direct message.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getDirectMessagesById($id)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('direct_messages', 'show');
|
||||
|
||||
// Set the API path
|
||||
$path = '/direct_messages/show.json';
|
||||
|
||||
$data['id'] = $id;
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete the direct message specified in the required ID parameter.
|
||||
*
|
||||
* @param integer $id The ID of the direct message.
|
||||
* @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety of metadata
|
||||
* about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function deleteDirectMessages($id, $entities = null)
|
||||
{
|
||||
// Set the API path
|
||||
$path = '/direct_messages/destroy.json';
|
||||
|
||||
$data['id'] = $id;
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
}
|
134
libraries/joomla/twitter/favorites.php
Normal file
134
libraries/joomla/twitter/favorites.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Favorites class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterFavorites extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get the most recent favorite statuses for the authenticating or specified user.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param integer $count Specifies the number of tweets to try and retrieve, up to a maximum of 200. Retweets are always included
|
||||
* in the count, so it is always suggested to set $include_rts to true
|
||||
* @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
||||
* @param integer $max_id Returns results with an ID less than (that is, older than) the specified ID.
|
||||
* @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety
|
||||
* of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getFavorites($user = null, $count = 20, $since_id = 0, $max_id = 0, $entities = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('favorites', 'list');
|
||||
|
||||
// Set the API path.
|
||||
$path = '/favorites/list.json';
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
|
||||
// Set the count string
|
||||
$data['count'] = $count;
|
||||
|
||||
// Check if since_id is specified.
|
||||
if ($since_id > 0)
|
||||
{
|
||||
$data['since_id'] = $since_id;
|
||||
}
|
||||
|
||||
// Check if max_id is specified.
|
||||
if ($max_id > 0)
|
||||
{
|
||||
$data['max_id'] = $max_id;
|
||||
}
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to favorite the status specified in the ID parameter as the authenticating user
|
||||
*
|
||||
* @param integer $id The numerical ID of the desired status.
|
||||
* @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety
|
||||
* of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function createFavorites($id, $entities = null)
|
||||
{
|
||||
// Set the API path.
|
||||
$path = '/favorites/create.json';
|
||||
|
||||
$data['id'] = $id;
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to un-favorites the status specified in the ID parameter as the authenticating user.
|
||||
*
|
||||
* @param integer $id The numerical ID of the desired status.
|
||||
* @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety
|
||||
* of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function deleteFavorites($id, $entities = null)
|
||||
{
|
||||
// Set the API path.
|
||||
$path = '/favorites/destroy.json';
|
||||
|
||||
$data['id'] = $id;
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
}
|
459
libraries/joomla/twitter/friends.php
Normal file
459
libraries/joomla/twitter/friends.php
Normal file
@ -0,0 +1,459 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Friends class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterFriends extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get an array of user IDs the specified user follows.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param integer $cursor Causes the list of connections to be broken into pages of no more than 5000 IDs at a time.
|
||||
* The number of IDs returned is not guaranteed to be 5000 as suspended users are filtered out
|
||||
* after connections are queried. If no cursor is provided, a value of -1 will be assumed, which is the first "page."
|
||||
* @param boolean $string_ids Set to true to return IDs as strings, false to return as integers.
|
||||
* @param integer $count Specifies the number of IDs attempt retrieval of, up to a maximum of 5,000 per distinct request.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getFriendIds($user, $cursor = null, $string_ids = null, $count = 0)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('friends', 'ids');
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Check if cursor is specified
|
||||
if (!is_null($cursor))
|
||||
{
|
||||
$data['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
// Check if string_ids is true
|
||||
if ($string_ids)
|
||||
{
|
||||
$data['stringify_ids'] = $string_ids;
|
||||
}
|
||||
|
||||
// Check if count is specified
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/friends/ids.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to display detailed friend information between two users.
|
||||
*
|
||||
* @param mixed $user_a Either an integer containing the user ID or a string containing the screen name of the first user.
|
||||
* @param mixed $user_b Either an integer containing the user ID or a string containing the screen name of the second user.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getFriendshipDetails($user_a, $user_b)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('friendships', 'show');
|
||||
|
||||
// Determine which type of data was passed for $user_a
|
||||
if (is_numeric($user_a))
|
||||
{
|
||||
$data['source_id'] = $user_a;
|
||||
}
|
||||
elseif (is_string($user_a))
|
||||
{
|
||||
$data['source_screen_name'] = $user_a;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The first specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Determine which type of data was passed for $user_b
|
||||
if (is_numeric($user_b))
|
||||
{
|
||||
$data['target_id'] = $user_b;
|
||||
}
|
||||
elseif (is_string($user_b))
|
||||
{
|
||||
$data['target_screen_name'] = $user_b;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The second specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/friendships/show.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of user IDs the specified user is followed by.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param integer $cursor Causes the list of IDs to be broken into pages of no more than 5000 IDs at a time. The number of IDs returned
|
||||
* is not guaranteed to be 5000 as suspended users are filtered out after connections are queried. If no cursor
|
||||
* is provided, a value of -1 will be assumed, which is the first "page."
|
||||
* @param boolean $string_ids Set to true to return IDs as strings, false to return as integers.
|
||||
* @param integer $count Specifies the number of IDs attempt retrieval of, up to a maximum of 5,000 per distinct request.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getFollowerIds($user, $cursor = null, $string_ids = null, $count = 0)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('followers', 'ids');
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/followers/ids.json';
|
||||
|
||||
// Check if cursor is specified
|
||||
if (!is_null($cursor))
|
||||
{
|
||||
$data['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
// Check if string_ids is specified
|
||||
if (!is_null($string_ids))
|
||||
{
|
||||
$data['stringify_ids'] = $string_ids;
|
||||
}
|
||||
|
||||
// Check if count is specified
|
||||
if (!is_null($count))
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to determine pending requests to follow the authenticating user.
|
||||
*
|
||||
* @param integer $cursor Causes the list of IDs to be broken into pages of no more than 5000 IDs at a time. The number of IDs returned
|
||||
* is not guaranteed to be 5000 as suspended users are filtered out after connections are queried. If no cursor
|
||||
* is provided, a value of -1 will be assumed, which is the first "page."
|
||||
* @param boolean $string_ids Set to true to return IDs as strings, false to return as integers.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getFriendshipsIncoming($cursor = null, $string_ids = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('friendships', 'incoming');
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if cursor is specified
|
||||
if (!is_null($cursor))
|
||||
{
|
||||
$data['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
// Check if string_ids is specified
|
||||
if (!is_null($string_ids))
|
||||
{
|
||||
$data['stringify_ids'] = $string_ids;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/friendships/incoming.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to determine every protected user for whom the authenticating user has a pending follow request.
|
||||
*
|
||||
* @param integer $cursor Causes the list of IDs to be broken into pages of no more than 5000 IDs at a time. The number of IDs returned
|
||||
* is not guaranteed to be 5000 as suspended users are filtered out after connections are queried. If no cursor
|
||||
* is provided, a value of -1 will be assumed, which is the first "page."
|
||||
* @param boolean $string_ids Set to true to return IDs as strings, false to return as integers.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getFriendshipsOutgoing($cursor = null, $string_ids = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('friendships', 'outgoing');
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if cursor is specified
|
||||
if (!is_null($cursor))
|
||||
{
|
||||
$data['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
// Check if string_ids is specified
|
||||
if (!is_null($string_ids))
|
||||
{
|
||||
$data['stringify_ids'] = $string_ids;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/friendships/outgoing.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the authenticating users to follow the user specified in the ID parameter.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param boolean $follow Enable notifications for the target user.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function follow($user, $follow = false)
|
||||
{
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Check if follow is true
|
||||
if ($follow)
|
||||
{
|
||||
$data['follow'] = $follow;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/friendships/create.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the authenticating users to unfollow the user specified in the ID parameter.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function unfollow($user)
|
||||
{
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/friendships/destroy.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the relationship of the authenticating user to the comma separated list of up to 100 screen_names or user_ids provided.
|
||||
*
|
||||
* @param string $screen_name A comma separated list of screen names, up to 100 are allowed in a single request.
|
||||
* @param string $id A comma separated list of user IDs, up to 100 are allowed in a single request.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getFriendshipsLookup($screen_name = null, $id = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('friendships', 'lookup');
|
||||
|
||||
// Set user IDs and screen names.
|
||||
if ($id)
|
||||
{
|
||||
$data['user_id'] = $id;
|
||||
}
|
||||
if ($screen_name)
|
||||
{
|
||||
$data['screen_name'] = $screen_name;
|
||||
}
|
||||
if ($id == null && $screen_name == null)
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('You must specify either a comma separated list of screen names, user IDs, or a combination of the two');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/friendships/lookup.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows one to enable or disable retweets and device notifications from the specified user.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param boolean $device Enable/disable device notifications from the target user.
|
||||
* @param boolean $retweets Enable/disable retweets from the target user.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function updateFriendship($user, $device = null, $retweets = null)
|
||||
{
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Check if device is specified.
|
||||
if (!is_null($device))
|
||||
{
|
||||
$data['device'] = $device;
|
||||
}
|
||||
|
||||
// Check if retweets is specified.
|
||||
if (!is_null($retweets))
|
||||
{
|
||||
$data['retweets'] = $retweets;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/friendships/update.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the user ids that currently authenticated user does not want to see retweets from.
|
||||
*
|
||||
* @param boolean $string_ids Set to true to return IDs as strings, false to return as integers.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getFriendshipNoRetweetIds($string_ids = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('friendships', 'no_retweets/ids');
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if string_ids is specified
|
||||
if (!is_null($string_ids))
|
||||
{
|
||||
$data['stringify_ids'] = $string_ids;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/friendships/no_retweets/ids.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
}
|
59
libraries/joomla/twitter/help.php
Normal file
59
libraries/joomla/twitter/help.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Help class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterHelp extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get the supported languages from the API.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getLanguages()
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('help', 'languages');
|
||||
|
||||
// Set the API path
|
||||
$path = '/help/languages.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the current configuration used by Twitter including twitter.com slugs which are not usernames,
|
||||
* maximum photo resolutions, and t.co URL lengths.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getConfiguration()
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('help', 'configuration');
|
||||
|
||||
// Set the API path
|
||||
$path = '/help/configuration.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path);
|
||||
}
|
||||
}
|
1
libraries/joomla/twitter/index.html
Normal file
1
libraries/joomla/twitter/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
982
libraries/joomla/twitter/lists.php
Normal file
982
libraries/joomla/twitter/lists.php
Normal file
@ -0,0 +1,982 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Lists class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterLists extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get all lists the authenticating or specified user subscribes to, including their own.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param boolean $reverse Set this to true if you would like owned lists to be returned first. See description
|
||||
* above for information on how this parameter works.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getLists($user, $reverse = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'list');
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Check if reverse is specified.
|
||||
if (!is_null($reverse))
|
||||
{
|
||||
$data['reverse'] = $reverse;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/list.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get tweet timeline for members of the specified list
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
||||
* @param integer $max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
||||
* @param integer $count Specifies the number of results to retrieve per "page."
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities". This node offers a variety
|
||||
* of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $include_rts When set to either true, t or 1, the list timeline will contain native retweets (if they exist) in addition
|
||||
* to the standard stream of tweets.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getStatuses($list, $owner = null, $since_id = 0, $max_id = 0, $count = 0, $entities = null, $include_rts = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'statuses');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/statuses.json';
|
||||
|
||||
// Check if since_id is specified
|
||||
if ($since_id > 0)
|
||||
{
|
||||
$data['since_id'] = $since_id;
|
||||
}
|
||||
|
||||
// Check if max_id is specified
|
||||
if ($max_id > 0)
|
||||
{
|
||||
$data['max_id'] = $max_id;
|
||||
}
|
||||
|
||||
// Check if count is specified
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if include_rts is specified
|
||||
if (!is_null($include_rts))
|
||||
{
|
||||
$data['include_rts'] = $include_rts;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the subscribers of the specified list.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param integer $cursor Breaks the results into pages. A single page contains 20 lists. Provide a value of -1 to begin paging.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities". This node offers a variety
|
||||
* of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getSubscribers($list, $owner = null, $cursor = null, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'subscribers');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/subscribers.json';
|
||||
|
||||
// Check if cursor is specified
|
||||
if (!is_null($cursor))
|
||||
{
|
||||
$data['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to remove multiple members from a list, by specifying a comma-separated list of member ids or screen names.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param string $user_id A comma separated list of user IDs, up to 100 are allowed in a single request.
|
||||
* @param string $screen_name A comma separated list of screen names, up to 100 are allowed in a single request.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function deleteMembers($list, $user_id = null, $screen_name = null, $owner = null)
|
||||
{
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username for owner is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
if ($user_id)
|
||||
{
|
||||
$data['user_id'] = $user_id;
|
||||
}
|
||||
if ($screen_name)
|
||||
{
|
||||
$data['screen_name'] = $screen_name;
|
||||
}
|
||||
if ($user_id == null && $screen_name == null)
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('You must specify either a comma separated list of screen names, user IDs, or a combination of the two');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/members/destroy_all.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to subscribe the authenticated user to the specified list.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function subscribe($list, $owner = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'subscribers/create');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username for owner is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/subscribers/create.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if the specified user is a member of the specified list.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name of the user to remove.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities". This node offers a
|
||||
* variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function isMember($list, $user, $owner = null, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'members/show');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/members/show.json';
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if the specified user is a subscriber of the specified list.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name of the user to remove.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities". This node offers a
|
||||
* variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function isSubscriber($list, $user, $owner = null, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'subscribers/show');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/subscribers/show.json';
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unsubscribe the authenticated user from the specified list.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function unsubscribe($list, $owner = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'subscribers/destroy');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/subscribers/destroy.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add multiple members to a list, by specifying a comma-separated list of member ids or screen names.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param string $user_id A comma separated list of user IDs, up to 100 are allowed in a single request.
|
||||
* @param string $screen_name A comma separated list of screen names, up to 100 are allowed in a single request.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function addMembers($list, $user_id = null, $screen_name = null, $owner = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'members/create_all');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
if ($user_id)
|
||||
{
|
||||
$data['user_id'] = $user_id;
|
||||
}
|
||||
if ($screen_name)
|
||||
{
|
||||
$data['screen_name'] = $screen_name;
|
||||
}
|
||||
if ($user_id == null && $screen_name == null)
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('You must specify either a comma separated list of screen names, user IDs, or a combination of the two');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/members/create_all.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the members of the specified list.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities". This node offers a variety
|
||||
* of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getMembers($list, $owner = null, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'members');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/members.json';
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the specified list.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getListById($list, $owner = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'show');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/show.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a collection of the lists the specified user is subscribed to, 20 lists per page by default. Does not include the user's own lists.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param integer $count The amount of results to return per page. Defaults to 20. Maximum of 1,000 when using cursors.
|
||||
* @param integer $cursor Breaks the results into pages. Provide a value of -1 to begin paging.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getSubscriptions($user, $count = 0, $cursor = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'subscriptions');
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if cursor is specified.
|
||||
if (!is_null($cursor))
|
||||
{
|
||||
$data['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/subscriptions.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update the specified list
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
|
||||
* @param string $name The name of the list.
|
||||
* @param string $mode Whether your list is public or private. Values can be public or private. If no mode is
|
||||
* specified the list will be public.
|
||||
* @param string $description The description to give the list.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function update($list, $owner = null, $name = null, $mode = null, $description = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'update');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Check if name is specified.
|
||||
if ($name)
|
||||
{
|
||||
$data['name'] = $name;
|
||||
}
|
||||
|
||||
// Check if mode is specified.
|
||||
if ($mode)
|
||||
{
|
||||
$data['mode'] = $mode;
|
||||
}
|
||||
|
||||
// Check if description is specified.
|
||||
if ($description)
|
||||
{
|
||||
$data['description'] = $description;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/update.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create a new list for the authenticated user.
|
||||
*
|
||||
* @param string $name The name of the list.
|
||||
* @param string $mode Whether your list is public or private. Values can be public or private. If no mode is
|
||||
* specified the list will be public.
|
||||
* @param string $description The description to give the list.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function create($name, $mode = null, $description = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'create');
|
||||
|
||||
// Check if name is specified.
|
||||
if ($name)
|
||||
{
|
||||
$data['name'] = $name;
|
||||
}
|
||||
|
||||
// Check if mode is specified.
|
||||
if ($mode)
|
||||
{
|
||||
$data['mode'] = $mode;
|
||||
}
|
||||
|
||||
// Check if description is specified.
|
||||
if ($description)
|
||||
{
|
||||
$data['description'] = $description;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/create.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a specified list.
|
||||
*
|
||||
* @param mixed $list Either an integer containing the list ID or a string containing the list slug.
|
||||
* @param mixed $owner Either an integer containing the user ID or a string containing the screen name of the owner.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function delete($list, $owner = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('lists', 'destroy');
|
||||
|
||||
// Determine which type of data was passed for $list
|
||||
if (is_numeric($list))
|
||||
{
|
||||
$data['list_id'] = $list;
|
||||
}
|
||||
elseif (is_string($list))
|
||||
{
|
||||
$data['slug'] = $list;
|
||||
|
||||
// In this case the owner is required.
|
||||
if (is_numeric($owner))
|
||||
{
|
||||
$data['owner_id'] = $owner;
|
||||
}
|
||||
elseif (is_string($owner))
|
||||
{
|
||||
$data['owner_screen_name'] = $owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username for owner is not in the correct format; must use integer or string');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified list is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/lists/destroy.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
}
|
133
libraries/joomla/twitter/oauth.php
Normal file
133
libraries/joomla/twitter/oauth.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Joomla Platform class for generating Twitter API access token.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterOAuth extends JOAuth1Client
|
||||
{
|
||||
/**
|
||||
* @var JRegistry Options for the JTwitterOauth object.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JRegistry $options JTwitterOauth options object.
|
||||
* @param JHttp $client The HTTP client object.
|
||||
* @param JInput $input The input object.
|
||||
* @param JApplicationWeb $application The application object.
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function __construct(JRegistry $options = null, JHttp $client = null, JInput $input = null, JApplicationWeb $application = null)
|
||||
{
|
||||
$this->options = isset($options) ? $options : new JRegistry;
|
||||
|
||||
$this->options->def('accessTokenURL', 'https://api.twitter.com/oauth/access_token');
|
||||
$this->options->def('authenticateURL', 'https://api.twitter.com/oauth/authenticate');
|
||||
$this->options->def('authoriseURL', 'https://api.twitter.com/oauth/authorize');
|
||||
$this->options->def('requestTokenURL', 'https://api.twitter.com/oauth/request_token');
|
||||
|
||||
// Call the JOAuth1Client constructor to setup the object.
|
||||
parent::__construct($this->options, $client, $input, $application);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to verify if the access token is valid by making a request.
|
||||
*
|
||||
* @return boolean Returns true if the access token is valid and false otherwise.
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function verifyCredentials()
|
||||
{
|
||||
$token = $this->getToken();
|
||||
|
||||
// Set the parameters.
|
||||
$parameters = array('oauth_token' => $token['key']);
|
||||
|
||||
// Set the API base
|
||||
$path = 'https://api.twitter.com/1.1/account/verify_credentials.json';
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauthRequest($path, 'GET', $parameters);
|
||||
|
||||
// Verify response
|
||||
if ($response->code == 200)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the session of the authenticating user, returning a null cookie.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function endSession()
|
||||
{
|
||||
$token = $this->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters = array('oauth_token' => $token['key']);
|
||||
|
||||
// Set the API base
|
||||
$path = 'https://api.twitter.com/1.1/account/end_session.json';
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauthRequest($path, 'POST', $parameters);
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to validate a response.
|
||||
*
|
||||
* @param string $url The request URL.
|
||||
* @param JHttpResponse $response The response to validate.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws DomainException
|
||||
*/
|
||||
public function validateResponse($url, $response)
|
||||
{
|
||||
if (strpos($url, 'verify_credentials') === false && $response->code != 200)
|
||||
{
|
||||
$error = json_decode($response->body);
|
||||
|
||||
if (property_exists($error, 'error'))
|
||||
{
|
||||
throw new DomainException($error->error);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = $error->errors;
|
||||
throw new DomainException($error[0]->message, $error[0]->code);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
226
libraries/joomla/twitter/object.php
Normal file
226
libraries/joomla/twitter/object.php
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API object class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
abstract class JTwitterObject
|
||||
{
|
||||
/**
|
||||
* @var JRegistry Options for the Twitter object.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* @var JHttp The HTTP client object to use in sending HTTP requests.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var JTwitterOAuth The OAuth client.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $oauth;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JRegistry &$options Twitter options object.
|
||||
* @param JTwitterHttp $client The HTTP client object.
|
||||
* @param JTwitterOAuth $oauth The OAuth client.
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function __construct(JRegistry &$options = null, JHttp $client = null, JTwitterOAuth $oauth = null)
|
||||
{
|
||||
$this->options = isset($options) ? $options : new JRegistry;
|
||||
$this->client = isset($client) ? $client : new JHttp($this->options);
|
||||
$this->oauth = $oauth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check the rate limit for the requesting IP address
|
||||
*
|
||||
* @param string $resource A resource or a comma-separated list of resource families you want to know the current rate limit disposition for.
|
||||
* @param string $action An action for the specified resource, if only one resource is specified.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function checkRateLimit($resource = null, $action = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$rate_limit = $this->getRateLimit($resource);
|
||||
|
||||
$property = '/' . $resource;
|
||||
|
||||
if (!is_null($action))
|
||||
{
|
||||
$property .= '/' . $action;
|
||||
}
|
||||
|
||||
if ($rate_limit->resources->$resource->$property->remaining == 0)
|
||||
{
|
||||
// The IP has exceeded the Twitter API rate limit
|
||||
throw new RuntimeException('This server has exceed the Twitter API rate limit for the given period. The limit will reset at '
|
||||
. $rate_limit->resources->$resource->$property->reset
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build and return a full request URL for the request. This method will
|
||||
* add appropriate pagination details if necessary and also prepend the API url
|
||||
* to have a complete URL for the request.
|
||||
*
|
||||
* @param string $path URL to inflect
|
||||
* @param array $parameters The parameters passed in the URL.
|
||||
*
|
||||
* @return string The request URL.
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function fetchUrl($path, $parameters = null)
|
||||
{
|
||||
if ($parameters)
|
||||
{
|
||||
foreach ($parameters as $key => $value)
|
||||
{
|
||||
if (strpos($path, '?') === false)
|
||||
{
|
||||
$path .= '?' . $key . '=' . $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$path .= '&' . $key . '=' . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get a new JUri object fousing the api url and given path.
|
||||
if (strpos($path, 'http://search.twitter.com/search.json') === false)
|
||||
{
|
||||
$uri = new JUri($this->options->get('api.url') . $path);
|
||||
}
|
||||
else
|
||||
{
|
||||
$uri = new JUri($path);
|
||||
}
|
||||
|
||||
return (string) $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve the rate limit for the requesting IP address
|
||||
*
|
||||
* @param string $resource A resource or a comma-separated list of resource families you want to know the current rate limit disposition for.
|
||||
*
|
||||
* @return array The JSON response decoded
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getRateLimit($resource)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/application/rate_limit_status.json';
|
||||
|
||||
if (!is_null($resource))
|
||||
{
|
||||
return $this->sendRequest($path, 'GET', array('resources' => $resource));
|
||||
}
|
||||
|
||||
return $this->sendRequest($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to send the request.
|
||||
*
|
||||
* @param string $path The path of the request to make
|
||||
* @param string $method The request method.
|
||||
* @param mixed $data Either an associative array or a string to be sent with the post request.
|
||||
* @param array $headers An array of name-value pairs to include in the header of the request
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function sendRequest($path, $method = 'GET', $data = array(), $headers = array())
|
||||
{
|
||||
// Get the access token.
|
||||
$token = $this->oauth->getToken();
|
||||
|
||||
// Set parameters.
|
||||
$parameters['oauth_token'] = $token['key'];
|
||||
|
||||
// Send the request.
|
||||
$response = $this->oauth->oauthRequest($this->fetchUrl($path), $method, $parameters, $data, $headers);
|
||||
|
||||
if (strpos($path, 'update_with_media') !== false)
|
||||
{
|
||||
// Check Media Rate Limit.
|
||||
$response_headers = $response->headers;
|
||||
|
||||
if ($response_headers['x-mediaratelimit-remaining'] == 0)
|
||||
{
|
||||
// The IP has exceeded the Twitter API media rate limit
|
||||
throw new RuntimeException('This server has exceed the Twitter API media rate limit for the given period. The limit will reset in '
|
||||
. $response_headers['x-mediaratelimit-reset'] . 'seconds.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($response->body, 'redirected') !== false)
|
||||
{
|
||||
return $response->headers['Location'];
|
||||
}
|
||||
|
||||
return json_decode($response->body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option from the JTwitterObject instance.
|
||||
*
|
||||
* @param string $key The name of the option to get.
|
||||
*
|
||||
* @return mixed The option value.
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getOption($key)
|
||||
{
|
||||
return $this->options->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the JTwitterObject instance.
|
||||
*
|
||||
* @param string $key The name of the option to set.
|
||||
* @param mixed $value The option value to set.
|
||||
*
|
||||
* @return JTwitterObject This object for method chaining.
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function setOption($key, $value)
|
||||
{
|
||||
$this->options->set($key, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
291
libraries/joomla/twitter/places.php
Normal file
291
libraries/joomla/twitter/places.php
Normal file
@ -0,0 +1,291 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Places & Geo class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterPlaces extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get all the information about a known place.
|
||||
*
|
||||
* @param string $id A place in the world. These IDs can be retrieved using getGeocode.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getPlace($id)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('geo', 'id/:place_id');
|
||||
|
||||
// Set the API path
|
||||
$path = '/geo/id/' . $id . '.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get up to 20 places that can be used as a place_id when updating a status.
|
||||
*
|
||||
* @param float $lat The latitude to search around.
|
||||
* @param float $long The longitude to search around.
|
||||
* @param string $accuracy A hint on the "region" in which to search. If a number, then this is a radius in meters,
|
||||
* but it can also take a string that is suffixed with ft to specify feet.
|
||||
* @param string $granularity This is the minimal granularity of place types to return and must be one of: poi, neighborhood,
|
||||
* city, admin or country.
|
||||
* @param integer $max_results A hint as to the number of results to return.
|
||||
* @param string $callback If supplied, the response will use the JSONP format with a callback of the given name.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getGeocode($lat, $long, $accuracy = null, $granularity = null, $max_results = 0, $callback = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('geo', 'reverse_geocode');
|
||||
|
||||
// Set the API path
|
||||
$path = '/geo/reverse_geocode.json';
|
||||
|
||||
// Set the request parameters
|
||||
$data['lat'] = $lat;
|
||||
$data['long'] = $long;
|
||||
|
||||
// Check if accuracy is specified
|
||||
if ($accuracy)
|
||||
{
|
||||
$data['accuracy'] = $accuracy;
|
||||
}
|
||||
|
||||
// Check if granularity is specified
|
||||
if ($granularity)
|
||||
{
|
||||
$data['granularity'] = $granularity;
|
||||
}
|
||||
|
||||
// Check if max_results is specified
|
||||
if ($max_results)
|
||||
{
|
||||
$data['max_results'] = $max_results;
|
||||
}
|
||||
|
||||
// Check if callback is specified
|
||||
if ($callback)
|
||||
{
|
||||
$data['callback'] = $callback;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to search for places that can be attached to a statuses/update.
|
||||
*
|
||||
* @param float $lat The latitude to search around.
|
||||
* @param float $long The longitude to search around.
|
||||
* @param string $query Free-form text to match against while executing a geo-based query, best suited for finding nearby
|
||||
* locations by name.
|
||||
* @param string $ip An IP address.
|
||||
* @param string $granularity This is the minimal granularity of place types to return and must be one of: poi, neighborhood, city,
|
||||
* admin or country.
|
||||
* @param string $accuracy A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can
|
||||
* also take a string that is suffixed with ft to specify feet.
|
||||
* @param integer $max_results A hint as to the number of results to return.
|
||||
* @param string $within This is the place_id which you would like to restrict the search results to.
|
||||
* @param string $attribute This parameter searches for places which have this given street address.
|
||||
* @param string $callback If supplied, the response will use the JSONP format with a callback of the given name.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function search($lat = null, $long = null, $query = null, $ip = null, $granularity = null, $accuracy = null, $max_results = 0,
|
||||
$within = null, $attribute = null, $callback = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('geo', 'search');
|
||||
|
||||
// Set the API path
|
||||
$path = '/geo/search.json';
|
||||
|
||||
// At least one of the following parameters must be provided: lat, long, ip, or query.
|
||||
if ($lat == null && $long == null && $ip == null && $query == null)
|
||||
{
|
||||
throw new RuntimeException('At least one of the following parameters must be provided: lat, long, ip, or query.');
|
||||
}
|
||||
|
||||
// Check if lat is specified.
|
||||
if ($lat)
|
||||
{
|
||||
$data['lat'] = $lat;
|
||||
}
|
||||
|
||||
// Check if long is specified.
|
||||
if ($long)
|
||||
{
|
||||
$data['long'] = $long;
|
||||
}
|
||||
|
||||
// Check if query is specified.
|
||||
if ($query)
|
||||
{
|
||||
$data['query'] = rawurlencode($query);
|
||||
}
|
||||
|
||||
// Check if ip is specified.
|
||||
if ($ip)
|
||||
{
|
||||
$data['ip'] = $ip;
|
||||
}
|
||||
|
||||
// Check if granularity is specified
|
||||
if ($granularity)
|
||||
{
|
||||
$data['granularity'] = $granularity;
|
||||
}
|
||||
|
||||
// Check if accuracy is specified
|
||||
if ($accuracy)
|
||||
{
|
||||
$data['accuracy'] = $accuracy;
|
||||
}
|
||||
|
||||
// Check if max_results is specified
|
||||
if ($max_results)
|
||||
{
|
||||
$data['max_results'] = $max_results;
|
||||
}
|
||||
|
||||
// Check if within is specified
|
||||
if ($within)
|
||||
{
|
||||
$data['contained_within'] = $within;
|
||||
}
|
||||
|
||||
// Check if attribute is specified
|
||||
if ($attribute)
|
||||
{
|
||||
$data['attribute:street_address'] = rawurlencode($attribute);
|
||||
}
|
||||
|
||||
// Check if callback is specified
|
||||
if ($callback)
|
||||
{
|
||||
$data['callback'] = $callback;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to locate places near the given coordinates which are similar in name.
|
||||
*
|
||||
* @param float $lat The latitude to search around.
|
||||
* @param float $long The longitude to search around.
|
||||
* @param string $name The name a place is known as.
|
||||
* @param string $within This is the place_id which you would like to restrict the search results to.
|
||||
* @param string $attribute This parameter searches for places which have this given street address.
|
||||
* @param string $callback If supplied, the response will use the JSONP format with a callback of the given name.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getSimilarPlaces($lat, $long, $name, $within = null, $attribute = null, $callback = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('geo', 'similar_places');
|
||||
|
||||
// Set the API path
|
||||
$path = '/geo/similar_places.json';
|
||||
|
||||
$data['lat'] = $lat;
|
||||
$data['long'] = $long;
|
||||
$data['name'] = rawurlencode($name);
|
||||
|
||||
// Check if within is specified
|
||||
if ($within)
|
||||
{
|
||||
$data['contained_within'] = $within;
|
||||
}
|
||||
|
||||
// Check if attribute is specified
|
||||
if ($attribute)
|
||||
{
|
||||
$data['attribute:street_address'] = rawurlencode($attribute);
|
||||
}
|
||||
|
||||
// Check if callback is specified
|
||||
if ($callback)
|
||||
{
|
||||
$data['callback'] = $callback;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create a new place object at the given latitude and longitude.
|
||||
*
|
||||
* @param float $lat The latitude to search around.
|
||||
* @param float $long The longitude to search around.
|
||||
* @param string $name The name a place is known as.
|
||||
* @param string $geo_token The token found in the response from geo/similar_places.
|
||||
* @param string $within This is the place_id which you would like to restrict the search results to.
|
||||
* @param string $attribute This parameter searches for places which have this given street address.
|
||||
* @param string $callback If supplied, the response will use the JSONP format with a callback of the given name.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function createPlace($lat, $long, $name, $geo_token, $within, $attribute = null, $callback = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('geo', 'place');
|
||||
|
||||
$data['lat'] = $lat;
|
||||
$data['long'] = $long;
|
||||
$data['name'] = rawurlencode($name);
|
||||
$data['token'] = $geo_token;
|
||||
$data['contained_within'] = $within;
|
||||
|
||||
// Check if attribute is specified
|
||||
if ($attribute)
|
||||
{
|
||||
$data['attribute:street_address'] = rawurlencode($attribute);
|
||||
}
|
||||
|
||||
// Check if callback is specified
|
||||
if ($callback)
|
||||
{
|
||||
$data['callback'] = $callback;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/geo/place.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
}
|
348
libraries/joomla/twitter/profile.php
Normal file
348
libraries/joomla/twitter/profile.php
Normal file
@ -0,0 +1,348 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Profile class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterProfile extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to et values that users are able to set under the "Account" tab of their settings page.
|
||||
*
|
||||
* @param string $name Full name associated with the profile. Maximum of 20 characters.
|
||||
* @param string $url URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
|
||||
* @param string $location The city or country describing where the user of the account is located. The contents are not normalized
|
||||
* or geocoded in any way. Maximum of 30 characters.
|
||||
* @param string $description A description of the user owning the account. Maximum of 160 characters.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
|
||||
* variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function updateProfile($name = null, $url = null, $location = null, $description = null, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('account', 'update_profile');
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if name is specified.
|
||||
if ($name)
|
||||
{
|
||||
$data['name'] = $name;
|
||||
}
|
||||
|
||||
// Check if url is specified.
|
||||
if ($url)
|
||||
{
|
||||
$data['url'] = $url;
|
||||
}
|
||||
|
||||
// Check if location is specified.
|
||||
if ($location)
|
||||
{
|
||||
$data['location'] = $location;
|
||||
}
|
||||
|
||||
// Check if description is specified.
|
||||
if ($description)
|
||||
{
|
||||
$data['description'] = $description;
|
||||
}
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified.
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/account/update_profile.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update the authenticating user's profile background image. This method can also be used to enable or disable the profile
|
||||
* background image.
|
||||
*
|
||||
* @param string $image The background image for the profile.
|
||||
* @param boolean $tile Whether or not to tile the background image.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
|
||||
* variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
* @param boolean $use Determines whether to display the profile background image or not.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function updateProfileBackgroundImage($image = null, $tile = false, $entities = null, $skip_status = null, $use = false)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('account', 'update_profile_background_image');
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if image is specified.
|
||||
if ($image)
|
||||
{
|
||||
$data['image'] = "@{$image}";
|
||||
}
|
||||
|
||||
// Check if url is true.
|
||||
if ($tile)
|
||||
{
|
||||
$data['tile'] = $tile;
|
||||
}
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified.
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Check if use is true.
|
||||
if ($use)
|
||||
{
|
||||
$data['use'] = $use;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/account/update_profile_background_image.json';
|
||||
|
||||
$header = array('Content-Type' => 'multipart/form-data', 'Expect' => '');
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update the authenticating user's profile image.
|
||||
*
|
||||
* @param string $image The background image for the profile.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
|
||||
* variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function updateProfileImage($image = null, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('account', 'update_profile_image');
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if image is specified.
|
||||
if ($image)
|
||||
{
|
||||
$data['image'] = "@{$image}";
|
||||
}
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified.
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/account/update_profile_image.json';
|
||||
|
||||
$header = array('Content-Type' => 'multipart/form-data', 'Expect' => '');
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com.
|
||||
*
|
||||
* @param string $background Profile background color.
|
||||
* @param string $link Profile link color.
|
||||
* @param string $sidebar_border Profile sidebar's border color.
|
||||
* @param string $sidebar_fill Profile sidebar's fill color.
|
||||
* @param string $text Profile text color.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
|
||||
* variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function updateProfileColors($background = null, $link = null, $sidebar_border = null, $sidebar_fill = null, $text = null,
|
||||
$entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('account', 'update_profile_colors');
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if background is specified.
|
||||
if ($background)
|
||||
{
|
||||
$data['profile_background_color'] = $background;
|
||||
}
|
||||
|
||||
// Check if link is specified.
|
||||
if ($link)
|
||||
{
|
||||
$data['profile_link_color'] = $link;
|
||||
}
|
||||
|
||||
// Check if sidebar_border is specified.
|
||||
if ($sidebar_border)
|
||||
{
|
||||
$data['profile_sidebar_border_color'] = $sidebar_border;
|
||||
}
|
||||
|
||||
// Check if sidebar_fill is specified.
|
||||
if ($sidebar_fill)
|
||||
{
|
||||
$data['profile_sidebar_fill_color'] = $sidebar_fill;
|
||||
}
|
||||
|
||||
// Check if text is specified.
|
||||
if ($text)
|
||||
{
|
||||
$data['profile_text_color'] = $text;
|
||||
}
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is true.
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/account/update_profile_colors.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the settings (including current trend, geo and sleep time information) for the authenticating user.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getSettings()
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('account', 'settings');
|
||||
|
||||
// Set the API path
|
||||
$path = '/account/settings.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to update the authenticating user's settings.
|
||||
*
|
||||
* @param integer $location The Yahoo! Where On Earth ID to use as the user's default trend location.
|
||||
* @param boolean $sleep_time When set to true, t or 1, will enable sleep time for the user.
|
||||
* @param integer $start_sleep The hour that sleep time should begin if it is enabled.
|
||||
* @param integer $end_sleep The hour that sleep time should end if it is enabled.
|
||||
* @param string $time_zone The timezone dates and times should be displayed in for the user. The timezone must be one of the
|
||||
* Rails TimeZone names.
|
||||
* @param string $lang The language which Twitter should render in for this user.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function updateSettings($location = null, $sleep_time = false, $start_sleep = null, $end_sleep = null,
|
||||
$time_zone = null, $lang = null)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
// Check if location is specified.
|
||||
if ($location)
|
||||
{
|
||||
$data['trend_location_woeid '] = $location;
|
||||
}
|
||||
|
||||
// Check if sleep_time is true.
|
||||
if ($sleep_time)
|
||||
{
|
||||
$data['sleep_time_enabled'] = $sleep_time;
|
||||
}
|
||||
|
||||
// Check if start_sleep is specified.
|
||||
if ($start_sleep)
|
||||
{
|
||||
$data['start_sleep_time'] = $start_sleep;
|
||||
}
|
||||
|
||||
// Check if end_sleep is specified.
|
||||
if ($end_sleep)
|
||||
{
|
||||
$data['end_sleep_time'] = $end_sleep;
|
||||
}
|
||||
|
||||
// Check if time_zone is specified.
|
||||
if ($time_zone)
|
||||
{
|
||||
$data['time_zone'] = $time_zone;
|
||||
}
|
||||
|
||||
// Check if lang is specified.
|
||||
if ($lang)
|
||||
{
|
||||
$data['lang'] = $lang;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/account/settings.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
}
|
200
libraries/joomla/twitter/search.php
Normal file
200
libraries/joomla/twitter/search.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Search class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwittersearch extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get tweets that match a specified query.
|
||||
*
|
||||
* @param string $query Search query. Should be URL encoded. Queries will be limited by complexity.
|
||||
* @param string $callback If supplied, the response will use the JSONP format with a callback of the given name
|
||||
* @param string $geocode Returns tweets by users located within a given radius of the given latitude/longitude. The parameter value is
|
||||
* specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers).
|
||||
* @param string $lang Restricts tweets to the given language, given by an ISO 639-1 code.
|
||||
* @param string $locale Specify the language of the query you are sending (only ja is currently effective). This is intended for
|
||||
* language-specific clients and the default should work in the majority of cases.
|
||||
* @param string $result_type Specifies what type of search results you would prefer to receive. The current default is "mixed."
|
||||
* @param integer $count The number of tweets to return per page, up to a maximum of 100. Defaults to 15.
|
||||
* @param string $until Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD.
|
||||
* @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
||||
* @param integer $max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
|
||||
* variety of metadata about the tweet in a discrete structure, including: urls, media and hashtags.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function search($query, $callback = null, $geocode = null, $lang = null, $locale = null, $result_type = null, $count = 15,
|
||||
$until = null, $since_id = 0, $max_id = 0, $entities = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('search', 'tweets');
|
||||
|
||||
// Set the API path
|
||||
$path = '/search/tweets.json';
|
||||
|
||||
// Set query parameter.
|
||||
$data['q'] = rawurlencode($query);
|
||||
|
||||
// Check if callback is specified.
|
||||
if ($callback)
|
||||
{
|
||||
$data['callback'] = $callback;
|
||||
}
|
||||
|
||||
// Check if geocode is specified.
|
||||
if ($geocode)
|
||||
{
|
||||
$data['geocode'] = $geocode;
|
||||
}
|
||||
|
||||
// Check if lang is specified.
|
||||
if ($lang)
|
||||
{
|
||||
$data['lang'] = $lang;
|
||||
}
|
||||
|
||||
// Check if locale is specified.
|
||||
if ($locale)
|
||||
{
|
||||
$data['locale'] = $locale;
|
||||
}
|
||||
|
||||
// Check if result_type is specified.
|
||||
if ($result_type)
|
||||
{
|
||||
$data['result_type'] = $result_type;
|
||||
}
|
||||
|
||||
// Check if count is specified.
|
||||
if ($count != 15)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if until is specified.
|
||||
if ($until)
|
||||
{
|
||||
$data['until'] = $until;
|
||||
}
|
||||
|
||||
// Check if since_id is specified.
|
||||
if ($since_id > 0)
|
||||
{
|
||||
$data['since_id'] = $since_id;
|
||||
}
|
||||
|
||||
// Check if max_id is specified.
|
||||
if ($max_id > 0)
|
||||
{
|
||||
$data['max_id'] = $max_id;
|
||||
}
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the authenticated user's saved search queries.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getSavedSearches()
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('saved_searches', 'list');
|
||||
|
||||
// Set the API path
|
||||
$path = '/saved_searches/list.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the information for the saved search represented by the given id.
|
||||
*
|
||||
* @param integer $id The ID of the saved search.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getSavedSearchesById($id)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('saved_searches', 'show/:id');
|
||||
|
||||
// Set the API path
|
||||
$path = '/saved_searches/show/' . $id . '.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create a new saved search for the authenticated user.
|
||||
*
|
||||
* @param string $query The query of the search the user would like to save.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function createSavedSearch($query)
|
||||
{
|
||||
// Set the API path
|
||||
$path = '/saved_searches/create.json';
|
||||
|
||||
// Set POST request data
|
||||
$data['query'] = rawurlencode($query);
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete a saved search for the authenticating user.
|
||||
*
|
||||
* @param integer $id The ID of the saved search.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function deleteSavedSearch($id)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('saved_searches', 'destroy/:id');
|
||||
|
||||
// Set the API path
|
||||
$path = '/saved_searches/destroy/' . $id . '.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST');
|
||||
}
|
||||
}
|
657
libraries/joomla/twitter/statuses.php
Normal file
657
libraries/joomla/twitter/statuses.php
Normal file
@ -0,0 +1,657 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Statuses class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterStatuses extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get a single tweet with the given ID.
|
||||
*
|
||||
* @param integer $id The ID of the tweet to retrieve.
|
||||
* @param boolean $trim_user When set to true, each tweet returned in a timeline will include a user object including only
|
||||
* the status author's numerical ID.
|
||||
* @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety of metadata
|
||||
* about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $my_retweet When set to either true, t or 1, any statuses returned that have been retweeted by the authenticating user will
|
||||
* include an additional current_user_retweet node, containing the ID of the source status for the retweet.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getTweetById($id, $trim_user = null, $entities = null, $my_retweet = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit("statuses", "show/:id");
|
||||
|
||||
// Set the API base
|
||||
$path = '/statuses/show/' . $id . '.json';
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if trim_user is specified
|
||||
if (!is_null($trim_user))
|
||||
{
|
||||
$data['trim_user'] = $trim_user;
|
||||
}
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if my_retweet is specified
|
||||
if (!is_null($my_retweet))
|
||||
{
|
||||
$data['include_my_retweet'] = $my_retweet;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve the latest statuses from the specified user timeline.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param integer $count Specifies the number of tweets to try and retrieve, up to a maximum of 200. Retweets are always included
|
||||
* in the count, so it is always suggested to set $include_rts to true
|
||||
* @param boolean $include_rts When set to true, the timeline will contain native retweets in addition to the standard stream of tweets.
|
||||
* @param boolean $no_replies This parameter will prevent replies from appearing in the returned timeline. This parameter is only supported
|
||||
* for JSON and XML responses.
|
||||
* @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
||||
* @param integer $max_id Returns results with an ID less than (that is, older than) the specified ID.
|
||||
* @param boolean $trim_user When set to true, each tweet returned in a timeline will include a user object including only
|
||||
* the status author's numerical ID.
|
||||
* @param boolean $contributor This parameter enhances the contributors element of the status response to include the screen_name of the
|
||||
* contributor. By default only the user_id of the contributor is included.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getUserTimeline($user, $count = 20, $include_rts = null, $no_replies = null, $since_id = 0, $max_id = 0, $trim_user = null,
|
||||
$contributor = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('statuses', 'user_timeline');
|
||||
|
||||
$data = array();
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API base
|
||||
$path = '/statuses/user_timeline.json';
|
||||
|
||||
// Set the count string
|
||||
$data['count'] = $count;
|
||||
|
||||
// Check if include_rts is specified
|
||||
if (!is_null($include_rts))
|
||||
{
|
||||
$data['include_rts'] = $include_rts;
|
||||
}
|
||||
|
||||
// Check if no_replies is specified
|
||||
if (!is_null($no_replies))
|
||||
{
|
||||
$data['exclude_replies'] = $no_replies;
|
||||
}
|
||||
|
||||
// Check if a since_id is specified
|
||||
if ($since_id > 0)
|
||||
{
|
||||
$data['since_id'] = (int) $since_id;
|
||||
}
|
||||
|
||||
// Check if a max_id is specified
|
||||
if ($max_id > 0)
|
||||
{
|
||||
$data['max_id'] = (int) $max_id;
|
||||
}
|
||||
|
||||
// Check if trim_user is specified
|
||||
if (!is_null($trim_user))
|
||||
{
|
||||
$data['trim_user'] = $trim_user;
|
||||
}
|
||||
|
||||
// Check if contributor details is specified
|
||||
if (!is_null($contributor))
|
||||
{
|
||||
$data['contributor_details'] = $contributor;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a tweet.
|
||||
*
|
||||
* @param string $status The text of the tweet.
|
||||
* @param integer $in_reply_to_status_id The ID of an existing status that the update is in reply to.
|
||||
* @param float $lat The latitude of the location this tweet refers to.
|
||||
* @param float $long The longitude of the location this tweet refers to.
|
||||
* @param string $place_id A place in the world.
|
||||
* @param boolean $display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
|
||||
* @param boolean $trim_user When set to true, each tweet returned in a timeline will include a user object including only
|
||||
* the status author's numerical ID.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function tweet($status, $in_reply_to_status_id = null, $lat = null, $long = null, $place_id = null, $display_coordinates = null,
|
||||
$trim_user = null)
|
||||
{
|
||||
// Set the API base.
|
||||
$path = '/statuses/update.json';
|
||||
|
||||
// Set POST data.
|
||||
$data = array('status' => utf8_encode($status));
|
||||
|
||||
// Check if in_reply_to_status_id is specified.
|
||||
if ($in_reply_to_status_id)
|
||||
{
|
||||
$data['in_reply_to_status_id'] = $in_reply_to_status_id;
|
||||
}
|
||||
|
||||
// Check if lat is specified.
|
||||
if ($lat)
|
||||
{
|
||||
$data['lat'] = $lat;
|
||||
}
|
||||
|
||||
// Check if long is specified.
|
||||
if ($long)
|
||||
{
|
||||
$data['long'] = $long;
|
||||
}
|
||||
|
||||
// Check if place_id is specified.
|
||||
if ($place_id)
|
||||
{
|
||||
$data['place_id'] = $place_id;
|
||||
}
|
||||
|
||||
// Check if display_coordinates is specified.
|
||||
if (!is_null($display_coordinates))
|
||||
{
|
||||
$data['display_coordinates'] = $display_coordinates;
|
||||
}
|
||||
|
||||
// Check if trim_user is specified.
|
||||
if (!is_null($trim_user))
|
||||
{
|
||||
$data['trim_user'] = $trim_user;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve the most recent mentions for the authenticating user.
|
||||
*
|
||||
* @param integer $count Specifies the number of tweets to try and retrieve, up to a maximum of 200. Retweets are always included
|
||||
* in the count, so it is always suggested to set $include_rts to true
|
||||
* @param boolean $include_rts When set to true, the timeline will contain native retweets in addition to the standard stream of tweets.
|
||||
* @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety of metadata
|
||||
* about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
||||
* @param integer $max_id Returns results with an ID less than (that is, older than) the specified ID.
|
||||
* @param boolean $trim_user When set to true, each tweet returned in a timeline will include a user object including only
|
||||
* the status author's numerical ID.
|
||||
* @param string $contributor This parameter enhances the contributors element of the status response to include the screen_name
|
||||
* of the contributor.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getMentions($count = 20, $include_rts = null, $entities = null, $since_id = 0, $max_id = 0,
|
||||
$trim_user = null, $contributor = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('statuses', 'mentions_timeline');
|
||||
|
||||
// Set the API base
|
||||
$path = '/statuses/mentions_timeline.json';
|
||||
|
||||
// Set the count string
|
||||
$data['count'] = $count;
|
||||
|
||||
// Check if include_rts is specified
|
||||
if (!is_null($include_rts))
|
||||
{
|
||||
$data['include_rts'] = $include_rts;
|
||||
}
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if a since_id is specified
|
||||
if ($since_id > 0)
|
||||
{
|
||||
$data['since_id'] = (int) $since_id;
|
||||
}
|
||||
|
||||
// Check if a max_id is specified
|
||||
if ($max_id > 0)
|
||||
{
|
||||
$data['max_id'] = (int) $max_id;
|
||||
}
|
||||
|
||||
// Check if trim_user is specified
|
||||
if (!is_null($trim_user))
|
||||
{
|
||||
$data['trim_user'] = $trim_user;
|
||||
}
|
||||
|
||||
// Check if contributor is specified
|
||||
if (!is_null($contributor))
|
||||
{
|
||||
$data['contributor_details'] = $contributor;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the most recent tweets of the authenticated user that have been retweeted by others.
|
||||
*
|
||||
* @param integer $count Specifies the number of tweets to try and retrieve, up to a maximum of 200. Retweets are always included
|
||||
* in the count, so it is always suggested to set $include_rts to true
|
||||
* @param integer $since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
||||
* @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety of metadata
|
||||
* about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
* @param boolean $user_entities The user entities node will be disincluded when set to false.
|
||||
* @param integer $max_id Returns results with an ID less than (that is, older than) the specified ID.
|
||||
* @param boolean $trim_user When set to true, each tweet returned in a timeline will include a user object including only
|
||||
* the status author's numerical ID.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getRetweetsOfMe($count = 20, $since_id = 0, $entities = null, $user_entities = null, $max_id = 0, $trim_user = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('statuses', 'retweets_of_me');
|
||||
|
||||
// Set the API path
|
||||
$path = '/statuses/retweets_of_me.json';
|
||||
|
||||
// Set the count string
|
||||
$data['count'] = $count;
|
||||
|
||||
// Check if a since_id is specified
|
||||
if ($since_id > 0)
|
||||
{
|
||||
$data['since_id'] = (int) $since_id;
|
||||
}
|
||||
|
||||
// Check if a max_id is specified
|
||||
if ($max_id > 0)
|
||||
{
|
||||
$data['max_id'] = (int) $max_id;
|
||||
}
|
||||
|
||||
// Check if trim_user is specified
|
||||
if (!is_null($trim_user))
|
||||
{
|
||||
$data['trim_user'] = $trim_user;
|
||||
}
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($user_entities))
|
||||
{
|
||||
$data['include_user_entities'] = $user_entities;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to show user objects of up to 100 members who retweeted the status.
|
||||
*
|
||||
* @param integer $id The numerical ID of the desired status.
|
||||
* @param integer $count Specifies the number of retweets to try and retrieve, up to a maximum of 100.
|
||||
* @param integer $cursor Causes the list of IDs to be broken into pages of no more than 100 IDs at a time.
|
||||
* The number of IDs returned is not guaranteed to be 100 as suspended users are
|
||||
* filtered out after connections are queried. If no cursor is provided, a value of
|
||||
* -1 will be assumed, which is the first "page."
|
||||
* @param boolean $stringify_ids Set to true to return IDs as strings, false to return as integers.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getRetweeters($id, $count = 20, $cursor = null, $stringify_ids = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('statuses', 'retweeters/ids');
|
||||
|
||||
// Set the API path
|
||||
$path = '/statuses/retweeters/ids.json';
|
||||
|
||||
// Set the status id.
|
||||
$data['id'] = $id;
|
||||
|
||||
// Set the count string
|
||||
$data['count'] = $count;
|
||||
|
||||
// Check if cursor is specified
|
||||
if (!is_null($cursor))
|
||||
{
|
||||
$data['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($stringify_ids))
|
||||
{
|
||||
$data['stringify_ids'] = $stringify_ids;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get up to 100 of the first retweets of a given tweet.
|
||||
*
|
||||
* @param integer $id The numerical ID of the desired status.
|
||||
* @param integer $count Specifies the number of tweets to try and retrieve, up to a maximum of 200. Retweets are always included
|
||||
* in the count, so it is always suggested to set $include_rts to true
|
||||
* @param boolean $trim_user When set to true, each tweet returned in a timeline will include a user object including only
|
||||
* the status author's numerical ID.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getRetweetsById($id, $count = 20, $trim_user = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('statuses', 'retweets/:id');
|
||||
|
||||
// Set the API path
|
||||
$path = '/statuses/retweets/' . $id . '.json';
|
||||
|
||||
// Set the count string
|
||||
$data['count'] = $count;
|
||||
|
||||
// Check if trim_user is specified
|
||||
if (!is_null($trim_user))
|
||||
{
|
||||
$data['trim_user'] = $trim_user;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete the status specified by the required ID parameter.
|
||||
*
|
||||
* @param integer $id The numerical ID of the desired status.
|
||||
* @param boolean $trim_user When set to true, each tweet returned in a timeline will include a user object including only
|
||||
* the status author's numerical ID.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function deleteTweet($id, $trim_user = null)
|
||||
{
|
||||
// Set the API path
|
||||
$path = '/statuses/destroy/' . $id . '.json';
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if trim_user is specified
|
||||
if (!is_null($trim_user))
|
||||
{
|
||||
$data['trim_user'] = $trim_user;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retweet a tweet.
|
||||
*
|
||||
* @param integer $id The numerical ID of the desired status.
|
||||
* @param boolean $trim_user When set to true, each tweet returned in a timeline will include a user object including only
|
||||
* the status author's numerical ID.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function retweet($id, $trim_user = null)
|
||||
{
|
||||
// Set the API path
|
||||
$path = '/statuses/retweet/' . $id . '.json';
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if trim_user is specified
|
||||
if (!is_null($trim_user))
|
||||
{
|
||||
$data['trim_user'] = $trim_user;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to post a tweet with media.
|
||||
*
|
||||
* @param string $status The text of the tweet.
|
||||
* @param string $media File to upload
|
||||
* @param integer $in_reply_to_status_id The ID of an existing status that the update is in reply to.
|
||||
* @param float $lat The latitude of the location this tweet refers to.
|
||||
* @param float $long The longitude of the location this tweet refers to.
|
||||
* @param string $place_id A place in the world.
|
||||
* @param boolean $display_coordinates Whether or not to put a pin on the exact coordinates a tweet has been sent from.
|
||||
* @param boolean $sensitive Set to true for content which may not be suitable for every audience.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function tweetWithMedia($status, $media, $in_reply_to_status_id = null, $lat = null, $long = null, $place_id = null,
|
||||
$display_coordinates = null, $sensitive = null)
|
||||
{
|
||||
// Set the API request path.
|
||||
$path = '/statuses/update_with_media.json';
|
||||
|
||||
// Set POST data.
|
||||
$data = array(
|
||||
'status' => utf8_encode($status),
|
||||
'media[]' => "@{$media}"
|
||||
);
|
||||
|
||||
$header = array('Content-Type' => 'multipart/form-data');
|
||||
|
||||
// Check if in_reply_to_status_id is specified.
|
||||
if (!is_null($in_reply_to_status_id))
|
||||
{
|
||||
$data['in_reply_to_status_id'] = $in_reply_to_status_id;
|
||||
}
|
||||
|
||||
// Check if lat is specified.
|
||||
if ($lat)
|
||||
{
|
||||
$data['lat'] = $lat;
|
||||
}
|
||||
|
||||
// Check if long is specified.
|
||||
if ($long)
|
||||
{
|
||||
$data['long'] = $long;
|
||||
}
|
||||
|
||||
// Check if place_id is specified.
|
||||
if ($place_id)
|
||||
{
|
||||
$data['place_id'] = $place_id;
|
||||
}
|
||||
|
||||
// Check if display_coordinates is specified.
|
||||
if (!is_null($display_coordinates))
|
||||
{
|
||||
$data['display_coordinates'] = $display_coordinates;
|
||||
}
|
||||
|
||||
// Check if sensitive is specified.
|
||||
if (!is_null($sensitive))
|
||||
{
|
||||
$data['possibly_sensitive'] = $sensitive;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get information allowing the creation of an embedded representation of a Tweet on third party sites.
|
||||
* Note: either the id or url parameters must be specified in a request. It is not necessary to include both.
|
||||
*
|
||||
* @param integer $id The Tweet/status ID to return embed code for.
|
||||
* @param string $url The URL of the Tweet/status to be embedded.
|
||||
* @param integer $maxwidth The maximum width in pixels that the embed should be rendered at. This value is constrained to be
|
||||
* between 250 and 550 pixels.
|
||||
* @param boolean $hide_media Specifies whether the embedded Tweet should automatically expand images which were uploaded via
|
||||
* POST statuses/update_with_media.
|
||||
* @param boolean $hide_thread Specifies whether the embedded Tweet should automatically show the original message in the case that
|
||||
* the embedded Tweet is a reply.
|
||||
* @param boolean $omit_script Specifies whether the embedded Tweet HTML should include a <script> element pointing to widgets.js. In cases where
|
||||
* a page already includes widgets.js, setting this value to true will prevent a redundant script element from being included.
|
||||
* @param string $align Specifies whether the embedded Tweet should be left aligned, right aligned, or centered in the page.
|
||||
* Valid values are left, right, center, and none.
|
||||
* @param string $related A value for the TWT related parameter, as described in Web Intents. This value will be forwarded to all
|
||||
* Web Intents calls.
|
||||
* @param string $lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getOembed($id = null, $url = null, $maxwidth = null, $hide_media = null, $hide_thread = null, $omit_script = null,
|
||||
$align = null, $related = null, $lang = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits.
|
||||
$this->checkRateLimit('statuses', 'oembed');
|
||||
|
||||
// Set the API request path.
|
||||
$path = '/statuses/oembed.json';
|
||||
|
||||
// Determine which of $id and $url is specified.
|
||||
if ($id)
|
||||
{
|
||||
$data['id'] = $id;
|
||||
}
|
||||
elseif ($url)
|
||||
{
|
||||
$data['url'] = rawurlencode($url);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry.
|
||||
throw new RuntimeException('Either the id or url parameters must be specified in a request.');
|
||||
}
|
||||
|
||||
// Check if maxwidth is specified.
|
||||
if ($maxwidth)
|
||||
{
|
||||
$data['maxwidth'] = $maxwidth;
|
||||
}
|
||||
|
||||
// Check if hide_media is specified.
|
||||
if (!is_null($hide_media))
|
||||
{
|
||||
$data['hide_media'] = $hide_media;
|
||||
}
|
||||
|
||||
// Check if hide_thread is specified.
|
||||
if (!is_null($hide_thread))
|
||||
{
|
||||
$data['hide_thread'] = $hide_thread;
|
||||
}
|
||||
|
||||
// Check if omit_script is specified.
|
||||
if (!is_null($omit_script))
|
||||
{
|
||||
$data['omit_script'] = $omit_script;
|
||||
}
|
||||
|
||||
// Check if align is specified.
|
||||
if ($align)
|
||||
{
|
||||
$data['align'] = $align;
|
||||
}
|
||||
|
||||
// Check if related is specified.
|
||||
if ($related)
|
||||
{
|
||||
$data['related'] = $related;
|
||||
}
|
||||
|
||||
// Check if lang is specified.
|
||||
if ($lang)
|
||||
{
|
||||
$data['lang'] = $lang;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
}
|
106
libraries/joomla/twitter/trends.php
Normal file
106
libraries/joomla/twitter/trends.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Trends class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterTrends extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get the top 10 trending topics for a specific WOEID, if trending information is available for it.
|
||||
*
|
||||
* @param integer $id The Yahoo! Where On Earth ID of the location to return trending information for.
|
||||
* Global information is available by using 1 as the WOEID.
|
||||
* @param string $exclude Setting this equal to hashtags will remove all hashtags from the trends list.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getTrends($id, $exclude = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('trends', 'place');
|
||||
|
||||
// Set the API path
|
||||
$path = '/trends/place.json';
|
||||
|
||||
$data['id'] = $id;
|
||||
|
||||
// Check if exclude is specified
|
||||
if ($exclude)
|
||||
{
|
||||
$data['exclude'] = $exclude;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the locations that Twitter has trending topic information for.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getLocations()
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('trends', 'available');
|
||||
|
||||
// Set the API path
|
||||
$path = '/trends/available.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the locations that Twitter has trending topic information for, closest to a specified location.
|
||||
*
|
||||
* @param float $lat The latitude to search around.
|
||||
* @param float $long The longitude to search around.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getClosest($lat = null, $long = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('trends', 'closest');
|
||||
|
||||
// Set the API path
|
||||
$path = '/trends/closest.json';
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if lat is specified
|
||||
if ($lat)
|
||||
{
|
||||
$data['lat'] = $lat;
|
||||
}
|
||||
|
||||
// Check if long is specified
|
||||
if ($long)
|
||||
{
|
||||
$data['long'] = $long;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
}
|
187
libraries/joomla/twitter/twitter.php
Normal file
187
libraries/joomla/twitter/twitter.php
Normal file
@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Joomla Platform class for interacting with a Twitter API instance.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitter
|
||||
{
|
||||
/**
|
||||
* @var JRegistry Options for the GitHub object.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* @var JHttp The HTTP client object to use in sending HTTP requests.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var JTwitterOAuth The OAuth client.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $oauth;
|
||||
|
||||
/**
|
||||
* @var JTwitterFriends Twitter API object for friends.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $friends;
|
||||
|
||||
/**
|
||||
* @var JTwitterUsers Twitter API object for users.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $users;
|
||||
|
||||
/**
|
||||
* @var JTwitterHelp Twitter API object for help.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $help;
|
||||
|
||||
/**
|
||||
* @var JTwitterStatuses Twitter API object for statuses.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $statuses;
|
||||
|
||||
/**
|
||||
* @var JTwitterSearch Twitter API object for search.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $search;
|
||||
|
||||
/**
|
||||
* @var JTwitterFavorites Twitter API object for favorites.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $favorites;
|
||||
|
||||
/**
|
||||
* @var JTwitterDirectMessages Twitter API object for direct messages.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $directMessages;
|
||||
|
||||
/**
|
||||
* @var JTwitterLists Twitter API object for lists.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $lists;
|
||||
|
||||
/**
|
||||
* @var JTwitterPlaces Twitter API object for places & geo.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $places;
|
||||
|
||||
/**
|
||||
* @var JTwitterTrends Twitter API object for trends.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $trends;
|
||||
|
||||
/**
|
||||
* @var JTwitterBlock Twitter API object for block.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $block;
|
||||
|
||||
/**
|
||||
* @var JTwitterProfile Twitter API object for profile.
|
||||
* @since 12.3
|
||||
*/
|
||||
protected $profile;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param JTwitterOauth $oauth The oauth client.
|
||||
* @param JRegistry $options Twitter options object.
|
||||
* @param JHttp $client The HTTP client object.
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function __construct(JTwitterOAuth $oauth = null, JRegistry $options = null, JHttp $client = null)
|
||||
{
|
||||
$this->oauth = $oauth;
|
||||
$this->options = isset($options) ? $options : new JRegistry;
|
||||
$this->client = isset($client) ? $client : new JHttp($this->options);
|
||||
|
||||
// Setup the default API url if not already set.
|
||||
$this->options->def('api.url', 'https://api.twitter.com/1.1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to lazily create API objects
|
||||
*
|
||||
* @param string $name Name of property to retrieve
|
||||
*
|
||||
* @return JTwitterObject Twitter API object (statuses, users, favorites, etc.).
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
$class = 'JTwitter' . ucfirst($name);
|
||||
|
||||
if (class_exists($class))
|
||||
{
|
||||
if (false == isset($this->$name))
|
||||
{
|
||||
$this->$name = new $class($this->options, $this->client, $this->oauth);
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Argument %s produced an invalid class name: %s', $name, $class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option from the JTwitter instance.
|
||||
*
|
||||
* @param string $key The name of the option to get.
|
||||
*
|
||||
* @return mixed The option value.
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getOption($key)
|
||||
{
|
||||
return $this->options->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an option for the JTwitter instance.
|
||||
*
|
||||
* @param string $key The name of the option to set.
|
||||
* @param mixed $value The option value to set.
|
||||
*
|
||||
* @return JTwitter This object for method chaining.
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function setOption($key, $value)
|
||||
{
|
||||
$this->options->set($key, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
375
libraries/joomla/twitter/users.php
Normal file
375
libraries/joomla/twitter/users.php
Normal file
@ -0,0 +1,375 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die();
|
||||
|
||||
/**
|
||||
* Twitter API Users class for the Joomla Platform.
|
||||
*
|
||||
* @package Joomla.Platform
|
||||
* @subpackage Twitter
|
||||
* @since 12.3
|
||||
*/
|
||||
class JTwitterUsers extends JTwitterObject
|
||||
{
|
||||
/**
|
||||
* Method to get up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two.
|
||||
*
|
||||
* @param string $screen_name A comma separated list of screen names, up to 100 are allowed in a single request.
|
||||
* @param string $id A comma separated list of user IDs, up to 100 are allowed in a single request.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a variety of
|
||||
* metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getUsersLookup($screen_name = null, $id = null, $entities = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('users', 'lookup');
|
||||
|
||||
// Set user IDs and screen names.
|
||||
if ($id)
|
||||
{
|
||||
$data['user_id'] = $id;
|
||||
}
|
||||
if ($screen_name)
|
||||
{
|
||||
$data['screen_name'] = $screen_name;
|
||||
}
|
||||
if ($id == null && $screen_name == null)
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('You must specify either a comma separated list of screen names, user IDs, or a combination of the two');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/users/lookup.json';
|
||||
|
||||
// Check if string_ids is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'POST', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to access the profile banner in various sizes for the user with the indicated screen_name.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getUserProfileBanner($user)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('users', 'profile_banner');
|
||||
|
||||
// Set the API path
|
||||
$path = '/users/profile_banner.json';
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to search for users
|
||||
*
|
||||
* @param string $query The search query to run against people search.
|
||||
* @param integer $page Specifies the page of results to retrieve.
|
||||
* @param integer $count The number of people to retrieve. Maximum of 20 allowed per page.
|
||||
* @param boolean $entities When set to either true, t or 1, each tweet will include a node called "entities,". This node offers a
|
||||
* variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function searchUsers($query, $page = 0, $count = 0, $entities = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('users', 'search');
|
||||
|
||||
$data['q'] = rawurlencode($query);
|
||||
|
||||
// Check if page is specified.
|
||||
if ($page > 0 )
|
||||
{
|
||||
$data['page'] = $page;
|
||||
}
|
||||
|
||||
// Check if per_page is specified
|
||||
if ($count > 0)
|
||||
{
|
||||
$data['count'] = $count;
|
||||
}
|
||||
|
||||
// Check if entities is specified.
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/users/search.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get extended information of a given user, specified by ID or screen name as per the required id parameter.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param boolean $entities Set to true to return IDs as strings, false to return as integers.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getUser($user, $entities = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('users', 'show');
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/users/show.json';
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of users that the specified user can contribute to.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param boolean $entities Set to true to return IDs as strings, false to return as integers.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getContributees($user, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('users', 'contributees');
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/users/contributees.json';
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of users who can contribute to the specified account.
|
||||
*
|
||||
* @param mixed $user Either an integer containing the user ID or a string containing the screen name.
|
||||
* @param boolean $entities Set to true to return IDs as strings, false to return as integers.
|
||||
* @param boolean $skip_status When set to either true, t or 1 statuses will not be included in the returned user objects.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getContributors($user, $entities = null, $skip_status = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('users', 'contributors');
|
||||
|
||||
// Determine which type of data was passed for $user
|
||||
if (is_numeric($user))
|
||||
{
|
||||
$data['user_id'] = $user;
|
||||
}
|
||||
elseif (is_string($user))
|
||||
{
|
||||
$data['screen_name'] = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a valid entry
|
||||
throw new RuntimeException('The specified username is not in the correct format; must use integer or string');
|
||||
}
|
||||
|
||||
// Set the API path
|
||||
$path = '/users/contributors.json';
|
||||
|
||||
// Check if entities is specified
|
||||
if (!is_null($entities))
|
||||
{
|
||||
$data['include_entities'] = $entities;
|
||||
}
|
||||
|
||||
// Check if skip_status is specified
|
||||
if (!is_null($skip_status))
|
||||
{
|
||||
$data['skip_status'] = $skip_status;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method access to Twitter's suggested user list.
|
||||
*
|
||||
* @param boolean $lang Restricts the suggested categories to the requested language.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getSuggestions($lang = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('users', 'suggestions');
|
||||
|
||||
// Set the API path
|
||||
$path = '/users/suggestions.json';
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if entities is true
|
||||
if ($lang)
|
||||
{
|
||||
$data['lang'] = $lang;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* method to access the users in a given category of the Twitter suggested user list.
|
||||
*
|
||||
* @param string $slug The short name of list or a category.
|
||||
* @param boolean $lang Restricts the suggested categories to the requested language.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getSuggestionsSlug($slug, $lang = null)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('users', 'suggestions/:slug');
|
||||
|
||||
// Set the API path
|
||||
$path = '/users/suggestions/' . $slug . '.json';
|
||||
|
||||
$data = array();
|
||||
|
||||
// Check if entities is true
|
||||
if ($lang)
|
||||
{
|
||||
$data['lang'] = $lang;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path, 'GET', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to access the users in a given category of the Twitter suggested user list and return
|
||||
* their most recent status if they are not a protected user.
|
||||
*
|
||||
* @param string $slug The short name of list or a category.
|
||||
*
|
||||
* @return array The decoded JSON response
|
||||
*
|
||||
* @since 12.3
|
||||
*/
|
||||
public function getSuggestionsSlugMembers($slug)
|
||||
{
|
||||
// Check the rate limit for remaining hits
|
||||
$this->checkRateLimit('users', 'suggestions/:slug/members');
|
||||
|
||||
// Set the API path
|
||||
$path = '/users/suggestions/' . $slug . '/members.json';
|
||||
|
||||
// Send the request.
|
||||
return $this->sendRequest($path);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user