Source for file statuses.php
Documentation is available at statuses.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 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
* 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
public function getTweetById($id, $trim_user =
null, $entities =
null, $my_retweet =
null)
// Check the rate limit for remaining hits
$path =
'/statuses/show/' .
$id .
'.json';
// Check if trim_user is specified
$data['trim_user'] =
$trim_user;
// Check if entities is specified
$data['include_entities'] =
$entities;
// Check if my_retweet is specified
$data['include_my_retweet'] =
$my_retweet;
* 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
* @throws RuntimeException
public function getUserTimeline($user, $count =
20, $include_rts =
null, $no_replies =
null, $since_id =
0, $max_id =
0, $trim_user =
null,
// Check the rate limit for remaining hits
// Determine which type of data was passed for $user
$data['user_id'] =
$user;
$data['screen_name'] =
$user;
// We don't have a valid entry
throw
new RuntimeException('The specified username is not in the correct format; must use integer or string');
$path =
'/statuses/user_timeline.json';
// Check if include_rts is specified
$data['include_rts'] =
$include_rts;
// Check if no_replies is specified
$data['exclude_replies'] =
$no_replies;
// Check if a since_id is specified
$data['since_id'] = (int)
$since_id;
// Check if a max_id is specified
$data['max_id'] = (int)
$max_id;
// Check if trim_user is specified
$data['trim_user'] =
$trim_user;
// Check if contributor details is specified
$data['contributor_details'] =
$contributor;
* 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
public function tweet($status, $in_reply_to_status_id =
null, $lat =
null, $long =
null, $place_id =
null, $display_coordinates =
null,
$path =
'/statuses/update.json';
// 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.
// Check if long is specified.
// Check if place_id is specified.
$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.
$data['trim_user'] =
$trim_user;
* 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
* @return array The decoded JSON response
* @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
$path =
'/statuses/mentions_timeline.json';
// Check if include_rts is specified
$data['include_rts'] =
$include_rts;
// Check if entities is specified
$data['include_entities'] =
$entities;
// Check if a since_id is specified
$data['since_id'] = (int)
$since_id;
// Check if a max_id is specified
$data['max_id'] = (int)
$max_id;
// Check if trim_user is specified
$data['trim_user'] =
$trim_user;
// Check if contributor is specified
$data['contributor_details'] =
$contributor;
* 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
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
$path =
'/statuses/retweets_of_me.json';
// Check if a since_id is specified
$data['since_id'] = (int)
$since_id;
// Check if a max_id is specified
$data['max_id'] = (int)
$max_id;
// Check if trim_user is specified
$data['trim_user'] =
$trim_user;
// Check if entities is specified
$data['include_entities'] =
$entities;
// Check if entities is specified
$data['include_user_entities'] =
$user_entities;
* 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
public function getRetweeters($id, $count =
20, $cursor =
null, $stringify_ids =
null)
// Check the rate limit for remaining hits
$path =
'/statuses/retweeters/ids.json';
// Check if cursor is specified
$data['cursor'] =
$cursor;
// Check if entities is specified
$data['stringify_ids'] =
$stringify_ids;
* 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
// Check the rate limit for remaining hits
$path =
'/statuses/retweets/' .
$id .
'.json';
// Check if trim_user is specified
$data['trim_user'] =
$trim_user;
* 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
$path =
'/statuses/destroy/' .
$id .
'.json';
// Check if trim_user is specified
$data['trim_user'] =
$trim_user;
* 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
public function retweet($id, $trim_user =
null)
$path =
'/statuses/retweet/' .
$id .
'.json';
// Check if trim_user is specified
$data['trim_user'] =
$trim_user;
* 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
* @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';
$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.
// Check if long is specified.
// Check if place_id is specified.
$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.
$data['possibly_sensitive'] =
$sensitive;
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
* @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
* @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.
// Set the API request path.
$path =
'/statuses/oembed.json';
// Determine which of $id and $url is specified.
// 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.
$data['maxwidth'] =
$maxwidth;
// Check if hide_media is specified.
$data['hide_media'] =
$hide_media;
// Check if hide_thread is specified.
$data['hide_thread'] =
$hide_thread;
// Check if omit_script is specified.
$data['omit_script'] =
$omit_script;
// Check if align is specified.
// Check if related is specified.
$data['related'] =
$related;
// Check if lang is specified.
Documentation generated on Tue, 19 Nov 2013 15:14:20 +0100 by phpDocumentor 1.4.3