Twitter

Twitter class

author

Tijs Verkoyen php-twitter@verkoyen.eu

version 2.3.1
copyright

Copyright (c), Tijs Verkoyen. All rights reserved.

license

BSD License

package

Default

Methods

Default constructor

__construct(string $consumerKey = '', string $consumerSecret = '') 

Arguments

$consumerKey

string

The consumer key to use.

$consumerSecret

string

The consumer secret to use.

Default destructor

__destruct() 

Removes the uploaded profile banner for the authenticating user.

accountRemoveProfileBanner() : boolean

Response

boolean

Returns settings (including current trend, geo and sleep time information) for the authenticating user.

accountSettings() : array

Response

array

Updates the authenticating user's settings.

accountSettingsUpdate(\string[optional] $trendLocationWoeId = null, \bool[optional] $sleepTimeEnabled = null, \string[optional] $startSleepTime = null, \string[optional] $endSleepTime = null, \string[optional] $timeZone = null, \string[optional] $lang = null) : array

Arguments

$trendLocationWoeId

\string[optional]

The Yahoo! Where On Earth ID to use as the user's default trend location. Global information is available by using 1 as the WOEID. The woeid must be one of the locations returned by trendsAvailable.

$sleepTimeEnabled

\bool[optional]

When set to true, will enable sleep time for the user. Sleep time is the time when push or SMS notifications should not be sent to the user.

$startSleepTime

\string[optional]

The hour that sleep time should begin if it is enabled. The value for this parameter should be provided in ISO8601 format (i.e. 00-23). The time is considered to be in the same timezone as the user's time_zone setting.

$endSleepTime

\string[optional]

The hour that sleep time should end if it is enabled. The value for this parameter should be provided in ISO8601 format (i.e. 00-23). The time is considered to be in the same timezone as the user's time_zone setting.

$timeZone

\string[optional]

The timezone dates and times should be displayed in for the user. The timezone must be one of the Rails TimeZone names.

$lang

\string[optional]

The language which Twitter should render in for this user. The language must be specified by the appropriate two letter ISO 639-1 representation. Currently supported languages are provided by helpLanguages.

Response

array

Sets which device Twitter delivers updates to for the authenticating user. Sending none as the device parameter will disable SMS updates.

accountUpdateDeliveryDevice(string $device, \bool[optional] $includeEntities = null) : array

Arguments

$device

string

Must be one of: sms, none.

$includeEntities

\bool[optional]

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. While entities are opt-in on timelines at present, they will be made a default component of output in the future. See Tweet Entities for more detail on entities.

Response

array

Sets values that users are able to set under the "Account" tab of their settings page. Only the parameters specified will be updated.

accountUpdateProfile(\string[optional] $name = null, \string[optional] $url = null, \string[optional] $location = null, \string[optional] $description = null, \bool[optional] $includeEntities = null, \bool[optional] $skipStatus = null) : array

Arguments

$name

\string[optional]

Full name associated with the profile. Maximum of 20 characters.

$url

\string[optional]

URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.

$location

\string[optional]

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.

$description

\string[optional]

A description of the user owning the account. Maximum of 160 characters.

$includeEntities

\bool[optional]

The entities node will not be included when set to false.

$skipStatus

\bool[optional]

When set to true, statuses will not be included in the returned user objects.

Response

array

Updates the authenticating user's profile background image.

accountUpdateProfileBackgroundImage(string $image, \bool[optional] $tile = false, \bool[optional] $includeEntities = null) : array

Arguments

$image

string

The path to the background image for the profile. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be forceably scaled down.

$tile

\bool[optional]

Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.

$includeEntities

\bool[optional]

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.

Response

array

Not implemented yet

accountUpdateProfileBanner() 

Sets one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com.

accountUpdateProfileColors(\string[optional] $profileBackgroundColor = null, \string[optional] $profileTextColor = null, \string[optional] $profileLinkColor = null, \string[optional] $profileSidebarFillColor = null, \string[optional] $profileSidebarBorderColor = null, \bool[optional] $includeEntities = null) : array

Each parameter's value must be a valid hexidecimal value, and may be either three or six characters (ex: #fff or #ffffff).

Arguments

$profileBackgroundColor

\string[optional]

Profile background color.

$profileTextColor

\string[optional]

Profile text color.

$profileLinkColor

\string[optional]

Profile link color.

$profileSidebarFillColor

\string[optional]

Profile sidebar's background color.

$profileSidebarBorderColor

\string[optional]

Profile sidebar's border color.

$includeEntities

\bool[optional]

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.

Response

array

Updates the authenticating user's profile image.

accountUpdateProfileImage(string $image, \bool[optional] $includeEntities = null) : array

Arguments

$image

string

The path to the avatar image for the profile. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down.

$includeEntities

\bool[optional]

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.

Response

array

Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.

accountVerifyCredentials(\bool[optional] $includeEntities = null, \bool[optional] $skipStatus = null) : array

Arguments

$includeEntities

\bool[optional]

The entities node will not be included when set to false.

$skipStatus

\bool[optional]

When set to true, statuses will not be included in the returned user objects.

Response

array

Returns the current rate limits for methods belonging to the specified resource families.

applicationRateLimitStatus(array $resources = null) : string

Each 1.1 API resource belongs to a "resource family" which is indicated in its method documentation. You can typically determine a method's resource family from the first component of the path after the resource version. This method responds with a map of methods belonging to the families specified by the resources parameter, the current remaining uses for each of those resources within the current rate limiting window, and its expiration time in epoch time. It also includes a rate_limit_context field that indicates the current access token context. You may also issue requests to this method without any parameters to receive a map of all rate limited GET methods. If your application only uses a few of methods, please explicitly provide a resources parameter with the specified resource families you work with.

Arguments

$resources

array

A comma-separated list of resource families you want to know the current rate limit disposition for. For best performance, only specify the resource families pertinent to your application.

Response

string

Blocks the specified user from following the authenticating user. In addition the blocked user will not show in the authenticating users mentions or timeline (unless retweeted by another user). If a follow or friend relationship exists it is destroyed.

blocksCreate(\string[optional] $userId = null, \string[optional] $screenName = null, \bool[optional] $includeEntities = null, \bool[optional] $skipStatus = null) : array

Arguments

$userId

\string[optional]

The ID of the potentially blocked user. Helpful for disambiguating when a valid user ID is also a valid screen name.

$screenName

\string[optional]

The screen name of the potentially blocked user. Helpful for disambiguating when a valid screen name is also a user ID.

$includeEntities

\bool[optional]

The entities node will not be included when set to false.

$skipStatus

\bool[optional]

When set to either true, t or 1 statuses will not be included in the returned user objects.

Response

array

Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful. If relationships existed before the block was instated, they will not be restored.

blocksDestroy(\string[optional] $userId = null, \string[optional] $screenName = null, \bool[optional] $includeEntities = null, \bool[optional] $skipStatus = null) : array

Arguments

$userId

\string[optional]

The ID of the potentially blocked user. Helpful for disambiguating when a valid user ID is also a valid screen name.

$screenName

\string[optional]

The screen name of the potentially blocked user. Helpful for disambiguating when a valid screen name is also a user ID.

$includeEntities

\bool[optional]

The entities node will not be included when set to false.

$skipStatus

\bool[optional]

When set to either true, t or 1 statuses will not be included in the returned user objects.

Response

array

Returns an array of numeric user ids the authenticating user is blocking.

blocksIds(\string[optional] $cursor = null, \bool[optional] $stringifyIds = null) : array

Arguments

$cursor

\string[optional]

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."

$stringifyIds

\bool[optional]

Many programming environments will not consume our ids due to their size. Provide this option to have ids returned as strings instead.

Response

array

Not implemented yet

blocksList(\int[optional] $cursor = null, \bool[optional] $includeEntities = null, \bool[optional] $skipStatus = null) : array

Arguments

$cursor

\int[optional]

Causes the results to be broken into pages of no more than 20 records at a time. If no cursor is provided, a value of -1 will be assumed, which is the first "page."

$includeEntities

\bool[optional]

The user object entities node will be disincluded when set to false.

$skipStatus

\bool[optional]

When set to either true, t or 1 statuses will not be included in the returned user objects.

Response

array

Format the parameters as a querystring

buildQuery(array $parameters) : string

Arguments

$parameters

array

The parameters.

Response

string

All OAuth 1.0 requests use the same basic algorithm for creating a signature base string and a signature. The signature base string is composed of the HTTP method being used, followed by an ampersand ("&") and then the URL-encoded base URL being accessed, complete with path (but not query parameters), followed by an ampersand ("&"). Then, you take all query parameters and POST body parameters (when the POST body is of the URL-encoded type, otherwise the POST body is ignored), including the OAuth parameters necessary for negotiation with the request at hand, and sort them in lexicographical order by first parameter name and then parameter value (for duplicate parameters), all the while ensuring that both the key and the value for each parameter are URL encoded in isolation. Instead of using the equals ("=") sign to mark the key/value relationship, you use the URL-encoded form of "%3D". Each parameter is then joined by the URL-escaped ampersand sign, "%26".

calculateBaseString(string $url, string $method, array $parameters) : string

Arguments

$url

string

The URL.

$method

string

The method to use.

$parameters

array

The parameters.

Response

string

Build the Authorization header

calculateHeader(array $parameters, string $url) : string
later

: fix me

Arguments

$parameters

array

The parameters.

$url

string

The URL.

Response

string

Returns the 20 most recent direct messages sent to the authenticating user. Includes detailed information about the sender and recipient user. You can request up to 200 direct messages per call, up to a maximum of 800 incoming DMs.

directMessages(\string[optional] $sinceId = null, \string[optional] $maxId = null, \int[optional] $count = null, \int[optional] $page = null, \bool[optional] $includeEntities = null, \bool[optional] $skipStatus = null) : array

Important: This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.

Arguments

$sinceId

\string[optional]

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.

$maxId

\string[optional]

Returns results with an ID less than (that is, older than) or equal to the specified ID.

$count

\int[optional]

Specifies the number of direct messages to try and retrieve, up to a maximum of 200. The value of count is best thought of as a limit to the number of Tweets to return because suspended or deleted content is removed after the count has been applied.

$page

\int[optional]

Specifies the page of results to retrieve.

$includeEntities

\bool[optional]

The entities node will not be included when set to false.

$skipStatus

\bool[optional]

When set to either true, t or 1 statuses will not be included in the returned user objects.

Response

array

Destroys the direct message specified in the required ID parameter. The authenticating user must be the recipient of the specified direct message.

directMessagesDestroy(string $id, \bool[optional] $includeEntities = null) : array

Important: This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.

Arguments

$id

string

The ID of the direct message to delete.

$includeEntities

\bool[optional]

The entities node will not be included when set to false.

Response

array

Sends a new direct message to the specified user from the authenticating user. Requires both the user and text parameters and must be a POST. Returns the sent message in the requested format if successful.

directMessagesNew(\string[optional] $userId = null, \string[optional] $screenName = null, string $text) : array

Arguments

$userId

\string[optional]

The ID of the user who should receive the direct message. Helpful for disambiguating when a valid user ID is also a valid screen name.

$screenName

\string[optional]

The screen name of the user who should receive the direct message. Helpful for disambiguating when a valid screen name is also a user ID.

$text

string

The text of your direct message. Be sure to URL encode as necessary, and keep the message under 140 characters.

Response

array

Returns the 20 most recent direct messages sent by the authenticating user. Includes detailed information about the sender and recipient user. You can request up to 200 direct messages per call, up to a maximum of 800 outgoing DMs.

directMessagesSent(\string[optional] $sinceId = null, \string[optional] $maxId = null, \int[optional] $count = null, \int[optional] $page = null, \bool[optional] $includeEntities = null) : array

Important: This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.

Arguments

$sinceId

\string[optional]

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.

$maxId

\string[optional]

Returns results with an ID less than (that is, older than) or equal to the specified ID.

$count

\int[optional]

Specifies the number of records to retrieve. Must be less than or equal to 200.

$page

\int[optional]

Specifies the page of results to retrieve.

$includeEntities

\bool[optional]

The entities node will not be included when set to false.

Response

array

directMessagesShow

directMessagesShow(string $id) : array

Arguments

$id

string

The ID of the direct message.

Response

array

Make the call

doCall(string $url, \array[optional] $parameters = null, \bool[optional] $authenticate = false, \bool[optional] $method = 'GET', \string[optional] $filePath = null, \bool[optional] $expectJSON = true, \bool[optional] $returnHeaders = false) : string

Arguments

$url

string

The url to call.

$parameters

\array[optional]

Optional parameters.

$authenticate

\bool[optional]

Should we authenticate.

$method

\bool[optional]

The method to use. Possible values are GET, POST.

$filePath

\string[optional]

The path to the file to upload.

$expectJSON

\bool[optional]

Do we expect JSON.

$returnHeaders

\bool[optional]

Should the headers be returned?

Response

string

Make an call to the oAuth

doOAuthCall(string $method, \array[optional] $parameters = null) : array
todo

refactor me

Arguments

$method

string

The method.

$parameters

\array[optional]

The parameters.

Response

array

Favorites the status specified in the ID parameter as the authenticating user. Returns the favorite status when successful.

favoritesCreate(string $id, \bool[optional] $includeEntities = null) : array

This process invoked by this method is asynchronous. The immediately returned status may not indicate the resultant favorited status of the tweet. A 200 OK response from this method will indicate whether the intended action was successful or not.

Arguments

$id

string

The numerical ID of the desired status.

$includeEntities

\bool[optional]

The entities node will be omitted when set to false.

Response

array

Un-favorites the status specified in the ID parameter as the authenticating user. Returns the un-favorited status in the requested format when successful.

favoritesDestroy(string $id, \bool[optional] $includeEntities = null) : array

This process invoked by this method is asynchronous. The immediately returned status may not indicate the resultant favorited status of the tweet. A 200 OK response from this method will indicate whether the intended action was successful or not.

Arguments

$id

string

The numerical ID of the desired status.

$includeEntities

\bool[optional]

The entities node will be omitted when set to false.

Response

array

Returns the 20 most recent Tweets favorited by the authenticating or specified user.

favoritesList(\string[otpional] $userId = null, \string[otpional] $screenName = null, \int[optional] $count = 20, \string[otpional] $sinceId = null, \string[otpional] $maxId = null, \bool[optional] $includeEntities = null) : array

Arguments

$userId

\string[otpional]

The ID of the user for whom to return results for.

$screenName

\string[otpional]

The screen name of the user for whom to return results for.

$count

\int[optional]

Specifies the number of records to retrieve. Must be less than or equal to 200. Defaults to 20.

$sinceId

\string[otpional]

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.

$maxId

\string[otpional]

Returns results with an ID less than (that is, older than) or equal to the specified ID.

$includeEntities

\bool[optional]

The entities node will be omitted when set to false.

Response

array

Returns a cursored collection of user IDs for every user following the specified user.

followersIds(\string[optional] $userId = null, \string[optional] $screenName = null, \string[optional] $cursor = null, \bool[optional] $stringifyIds = true) : array

At this time, results are ordered with the most recent following first — however, this ordering is subject to unannounced change and eventual consistency issues. Results are given in groups of 5,000 user IDs and multiple "pages" of results can be navigated through using the next_cursor value in subsequent requests. See Using cursors to navigate collections for more information. This method is especially powerful when used in conjunction with GET users/lookup, a method that allows you to convert user IDs into full user objects in bulk.

Arguments

$userId

\string[optional]

The ID of the user for whom to return results for.

$screenName

\string[optional]

The screen name of the user for whom to return results for.

$cursor

\string[optional]

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." The response from the API will include a previous_cursor and next_cursor to allow paging back and forth

$stringifyIds

\bool[optional]

Many programming environments will not consume our Tweet ids due to their size. Provide this option to have ids returned as strings instead.

Response

array

Returns a cursored collection of user objects for users following the specified user.

followersList(\string[optional] $userId = null, \string[optional] $screenName = null, \int[optional] $cursor = null, \bool[optional] $includeEntities = null, \bool[optional] $skipStatus = null) : array

At this time, results are ordered with the most recent following first — however, this ordering is subject to unannounced change and eventual consistency issues. Results are given in groups of 20 users and multiple "pages" of results can be navigated through using the next_cursor value in subsequent requests. See Using cursors to navigate collections for more information.

Arguments

$userId

\string[optional]

The ID of the user for whom to return results for.

$screenName

\string[optional]

The screen name of the user for whom to return results for.

$cursor

\int[optional]

Causes the results to be broken into pages of no more than 20 records at a time. If no cursor is provided, a value of -1 will be assumed, which is the first "page."

$includeEntities

\bool[optional]

The user object entities node will be disincluded when set to false.

$skipStatus

\bool[optional]

When set to either true, t or 1 statuses will not be included in the returned user objects.

Response

array

Allows the authenticating users to follow the user specified in the ID parameter.

friendshipsCreate(\string[optional] $userId = null, \string[optional] $screenName = null, \bool[optional] $follow = false) : array

Returns the befriended user in the requested format when successful. Returns a string describing the failure condition when unsuccessful. If you are already friends with the user a HTTP 403 may be returned, though for performance reasons you may get a 200 OK message even if the friendship already exists. Actions taken in this method are asynchronous and changes will be eventually consistent.

Arguments

$userId

\string[optional]

The ID of the user for whom to befriend.

$screenName

\string[optional]

The screen name of the user for whom to befriend.

$follow

\bool[optional]

Enable notifications for the target user.

Response

array

Allows the authenticating user to unfollow the user specified in the ID parameter.

friendshipsDestroy(\string[optional] $userId = null, \string[optional] $screenName = null) : array

Returns the unfollowed user in the requested format when successful. Returns a string describing the failure condition when unsuccessful. Actions taken in this method are asynchronous and changes will be eventually consistent.

Arguments

$userId

\string[optional]

The ID of the user for whom to unfollow.

$screenName

\string[optional]

The screen name of the user for whom to unfollow.

Response

array

Returns a collection of numeric IDs for every user who has a pending request to follow the authenticating user.

friendshipsIncoming(\string[optional] $cursor = null, \bool[optional] $stringifyIds = true) : array

Arguments

$cursor

\string[optional]

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."

$stringifyIds

\bool[optional]

Many programming environments will not consume our Tweet ids due to their size. Provide this option to have ids returned as strings instead.

Response

array

Returns the relationships of the authenticating user to the comma-separated list of up to 100 screen_names or user_ids provided.

friendshipsLookup(\mixed[optional] $userIds = null, \mixed[optional] $screenNames = null) : array

Values for connections can be: following, following_requested, followed_by, none.

Arguments

$userIds

\mixed[optional]

An array of user IDs, up to 100 are allowed in a single request.

$screenNames

\mixed[optional]

An array of screen names, up to 100 are allowed in a single request.

Response

array

Returns a collection of numeric IDs for every protected user for whom the authenticating user has a pending follow request.

friendshipsOutgoing(\string[optional] $cursor = null, \bool[optional] $stringifyIds = true) : array

Arguments

$cursor

\string[optional]

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."

$stringifyIds

\bool[optional]

Many programming environments will not consume our Tweet ids due to their size. Provide this option to have ids returned as strings instead.

Response

array

Returns detailed information about the relationship between two arbitrary users.

friendshipsShow(\string[optional] $sourceId = null, \string[optional] $sourceScreenName = null, \string[optional] $targetId = null, \string[optional] $targetScreenName = null) : array

Arguments

$sourceId

\string[optional]

The user_id of the subject user.

$sourceScreenName

\string[optional]

The screen_name of the subject user.

$targetId

\string[optional]

The screen_name of the subject user.

$targetScreenName

\string[optional]

The screen_name of the target user.

Response

array

Allows one to enable or disable retweets and device notifications from the specified user.

friendshipsUpdate(\string[optional] $userId = null, \string[optional] $screenName = null, \bool[optional] $device = null, \bool[optional] $retweets = null) : array

Arguments

$userId

\string[optional]

The ID of the user for whom to befriend.

$screenName

\string[optional]

The screen name of the user for whom to befriend.

$device

\bool[optional]

Enable/disable device notifications from the target user.

$retweets

\bool[optional]

Enable/disable retweets from the target user.

Response

array

Returns a cursored collection of user IDs for every user the specified user is following (otherwise known as their "friends").

friendsIds(\string[optional] $userId = null, \string[optional] $screenName = null, \string[optional] $cursor = null, \bool[optional] $stringifyIds = null) : array

At this time, results are ordered with the most recent following first — however, this ordering is subject to unannounced change and eventual consistency issues. Results are given in groups of 5,000 user IDs and multiple "pages" of results can be navigated through using the next_cursor value in subsequent requests. See Using cursors to navigate collections for more information. This method is especially powerful when used in conjunction with GET users/lookup, a method that allows you to convert user IDs into full user objects in bulk.

Arguments

$userId

\string[optional]

The ID of the user for whom to return results for.

$screenName

\string[optional]

The screen name of the user for whom to return results for.

$cursor

\string[optional]

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." The response from the API will include a previous_cursor and next_cursor to allow paging back and forth

$stringifyIds

\bool[optional]

Many programming environments will not consume our Tweet ids due to their size. Provide this option to have ids returned as strings instead.

Response

array

Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").

friendsList(\string[optional] $userId = null, \string[optional] $screenName = null, \int[optional] $cursor = null, \bool[optional] $includeEntities = null, \bool[optional] $skipStatus = null) : array

At this time, results are ordered with the most recent following first — however, this ordering is subject to unannounced change and eventual consistency issues. Results are given in groups of 20 users and multiple "pages" of results can be navigated through using the next_cursor value in subsequent requests. See Using cursors to navigate collections for more information.

Arguments

$userId

\string[optional]

The ID of the user for whom to return results for.

$screenName

\string[optional]

The screen name of the user for whom to return results for.

$cursor

\int[optional]

Causes the results to be broken into pages of no more than 20 records at a time. If no cursor is provided, a value of -1 will be assumed, which is the first "page."

$includeEntities

\bool[optional]

The user object entities node will be disincluded when set to false.

$skipStatus

\bool[optional]

When set to either true, t or 1 statuses will not be included in the returned user objects.

Response

array

Returns all the information about a known place.

geoId(string $id) : array

Arguments

$id

string

A place in the world. These IDs can be retrieved from geo/reverse_geocode.

Response

array

Creates a new place at the given latitude and longitude.

geoPlace(string $name, string $containedWithin, string $token, float $lat, float $long, \array[optional] $attributes = null) : array

Arguments

$name

string

The name a place is known as.

$containedWithin

string

The place_id within which the new place can be found. Try and be as close as possible with the containing place. For example, for a room in a building, set the contained_within as the building place_id.

$token

string

The token found in the response from geo/similar_places.

$lat

float

The latitude the place is located at. This parameter will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding long parameter.

$long

float

The longitude the place is located at. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding lat parameter.

$attributes

\array[optional]

This parameter searches for places which have this given street address. There are other well-known, and application specific attributes available. Custom attributes are also permitted. This should be an key-value-pair-array.

Response

array

Given a latitude and a longitude, searches for up to 20 places that can be used as a place_id when updating a status.

geoReverseGeoCode(float $lat, float $long, \string[optional] $accuracy = null, \string[optional] $granularity = null, \int[optional] $maxResults = null) : array

This request is an informative call and will deliver generalized results about geography.

Arguments

$lat

float

The latitude to search around. This parameter will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding long parameter.

$long

float

The longitude to search around. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding lat parameter.

$accuracy

\string[optional]

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. If this is not passed in, then it is assumed to be 0m. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).

$granularity

\string[optional]

This is the minimal granularity of place types to return and must be one of: poi, neighborhood, city, admin or country. If no granularity is provided for the request neighborhood is assumed. Setting this to city, for example, will find places which have a type of city, admin or country.

$maxResults

\int[optional]

A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.

Response

array

Search for places that can be attached to a statuses/update. Given a latitude and a longitude pair, an IP address, or a name, this request will return a list of all the valid places that can be used as the place_id when updating a status.

geoSearch(\float[optional] $lat = null, \float[optional] $long = null, \string[optional] $query = null, \string[optional] $ip = null, \string[optional] $granularity = null, \string[optional] $accuracy = null, \int[optional] $maxResults = null, \string[optional] $containedWithin = null, \array[optional] $attributes = null) : array

Conceptually, a query can be made from the user's location, retrieve a list of places, have the user validate the location he or she is at, and then send the ID of this location with a call to POST statuses/update. This is the recommended method to use find places that can be attached to statuses/update. Unlike GET geo/reverse_geocode which provides raw data access, this endpoint can potentially re-order places with regards to the user who is authenticated. This approach is also preferred for interactive place matching with the user.

Arguments

$lat

\float[optional]

The latitude to search around. This parameter will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding long parameter.

$long

\float[optional]

The longitude to search around. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding lat parameter.

$query

\string[optional]

Free-form text to match against while executing a geo-based query, best suited for finding nearby locations by name. Remember to URL encode the query.

$ip

\string[optional]

An IP address. Used when attempting to fix geolocation based off of the user's IP address.

$granularity

\string[optional]

This is the minimal granularity of place types to return and must be one of: poi, neighborhood, city, admin or country. If no granularity is provided for the request neighborhood is assumed. Setting this to city, for example, will find places which have a type of city, admin or country.

$accuracy

\string[optional]

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. If this is not passed in, then it is assumed to be 0m. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).

$maxResults

\int[optional]

A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.

$containedWithin

\string[optional]

This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found. Specify a place_id. For example, to scope all results to places within "San Francisco, CA USA", you would specify a place_id of "5a110d312052166f"

$attributes

\array[optional]

This parameter searches for places which have this given street address. There are other well-known, and application specific attributes available. Custom attributes are also permitted. This should be an key-value-pair-array.

Response

array

Locates places near the given coordinates which are similar in name.

geoSimilarPlaces(float $lat, float $long, string $name, \string[optional] $containedWithin = null, \array[optional] $attributes = null) : array

Conceptually you would use this method to get a list of known places to choose from first. Then, if the desired place doesn't exist, make a request to POST geo/place to create a new one. The token contained in the response is the token needed to be able to create a new place.

Arguments

$lat

float

The latitude to search around. This parameter will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding long parameter.

$long

float

The longitude to search around. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding lat parameter.

$name

string

The name a place is known as.

$containedWithin

\string[optional]

This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found. Specify a place_id. For example, to scope all results to places within "San Francisco, CA USA", you would specify a place_id of "5a110d312052166f"

$attributes

\array[optional]

This parameter searches for places which have this given street address. There are other well-known, and application specific attributes available. Custom attributes are also permitted.

Response

array

Get the consumer key

getConsumerKey() : string

Response

string

Get the consumer secret

getConsumerSecret() : string

Response

string

Get the oAuth-token

getOAuthToken() : string

Response

string

Get the oAuth-token-secret

getOAuthTokenSecret() : string

Response

string

Get the timeout

getTimeOut() : integer

Response

integer

Get the useragent that will be used. Our version will be prepended to yours.

getUserAgent() : string

It will look like: "PHP Twitter/ "

Response

string

Returns the current configuration used by Twitter including twitter.com slugs which are not usernames, maximum photo resolutions, and t.co URL lengths.

helpConfiguration() : array

It is recommended applications request this endpoint when they are loaded, but no more than once a day.

Response

array

Returns the list of languages supported by Twitter along with their ISO 639-1 code. The ISO 639-1 code is the two letter value to use if you include lang with any of your requests.

helpLanguages() : array

Response

array

Returns Twitter's Privacy Policy

helpPrivacy() : array

Response

array

Returns the Twitter Terms of Service in the requested format. These are not the same as the Developer Rules of the Road.

helpTos() : array

Response

array

Build the signature for the data

hmacsha1(string $key, string $data) : string

Arguments

$key

string

The key to use for signing.

$data

string

The data that has to be signed.

Response

string

Not implemented yet

listsCreate() 

Not implemented yet

listsDestroy() 

Not implemented yet

listsList() 

Not implemented yet

listsMembers() 

Not implemented yet

listsMembersCreate() 

Not implemented yet

listsMembersCreateAll() 

Not implemented yet

listsMembersDestroy() 

Not implemented yet

listsMembersDestroyAll() 

Not implemented yet

listsMemberships() 

Not implemented yet

listsMembersShow() 

Not implemented yet

listsShow() 

Not implemented yet

listsStatuses() 

Not implemented yet

listsSubscribers() 

Not implemented yet

listsSubscribersCreate() 

Not implemented yet

listsSubscribersDestroy() 

Not implemented yet

listsSubscribersShow() 

Not implemented yet

listSubscriptions() 

Not implemented yet

listsUpdate() 

Allows a Consumer application to exchange the OAuth Request Token for an OAuth Access Token.

oAuthAccessToken(string $token, string $verifier) : array

This method fulfills Secion 6.3 of the OAuth 1.0 authentication flow.

Arguments

$token

string

The token to use.

$verifier

string

The verifier.

Response

array

Allows a Consumer application to use an OAuth request_token to request user authorization.

oAuthAuthenticate(string $token, \bool[optional] $force = false, \string[optional] $screen_name = false) 

This method is a replacement fulfills Secion 6.2 of the OAuth 1.0 authentication flow for applications using the Sign in with Twitter authentication flow. The method will use the currently logged in user as the account to for access authorization unless the force_login parameter is set to true

Arguments

$token

string

The token.

$force

\bool[optional]

Force the authentication.

$screen_name

\string[optional]

Prefill the username input box of the OAuth login.

Will redirect to the page to authorize the applicatione

oAuthAuthorize(string $token) 

Arguments

$token

string

The token.

Allows a Consumer application to obtain an OAuth Request Token to request user authorization.

oAuthRequestToken(\string[optional] $callbackURL = null) : array

This method fulfills Secion 6.1 of the OAuth 1.0 authentication flow.

Arguments

$callbackURL

\string[optional]

The callback URL.

Response

array

An array containg the token and the secret

The user specified in the id is blocked by the authenticated user and reported as a spammer.

reportSpam(\string[optional] $screenName = null, \string[optional] $userId = null) : array

Arguments

$screenName

\string[optional]

The ID or screen_name of the user you want to report as a spammer. Helpful for disambiguating when a valid screen name is also a user ID.

$userId

\string[optional]

The ID of the user you want to report as a spammer. Helpful for disambiguating when a valid user ID is also a valid screen name.

Response

array

Create a new saved search for the authenticated user. A user may only have 25 saved searches.

savedSearchesCreate(string $query) : array

Arguments

$query

string

The query of the search the user would like to save.

Response

array

Destroys a saved search for the authenticating user. The authenticating user must be the owner of saved search id being destroyed.

savedSearchesDestroy(string $id) : array

Arguments

$id

string

The ID of the saved search.

Response

array

Returns the authenticated user's saved search queries.

savedSearchesList() : array

Response

array

Retrieve the information for the saved search represented by the given id. The authenticating user must be the owner of saved search ID being requested.

savedSearchesShow(string $id) : array

Arguments

$id

string

The ID of the saved search.

Response

array

Returns tweets that match a specified query.

searchTweets(string $q, \string[optional] $geocode = null, \string[optional] $lang = null, \string[optional] $locale = null, \string[optional] $resultType = null, \int[optional] $count = null, \string[optional] $until = null, \string[optional] $sinceId = null, \string[optional] $maxId = null, \bool[optional] $includeEntities = null) : array

Arguments

$q

string

A UTF-8, URL-encoded search query of 1,000 characters maximum, including operators. Queries may additionally be limited by complexity.

$geocode

\string[optional]

Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly. A maximum of 1,000 distinct "sub-regions" will be considered when using the radius modifier.

$lang

\string[optional]

Restricts tweets to the given language, given by an ISO 639-1 code. Language detection is best-effort.

$locale

\string[optional]

Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific consumers and the default should work in the majority of cases.

$resultType

\string[optional]

Specifies what type of search results you would prefer to receive. The current default is "mixed." Valid values include: mixed: Include both popular and real time results in the response, recent: return only the most recent results in the response, popular: return only the most popular results in the response.

$count

\int[optional]

The number of tweets to return per page, up to a maximum of 100. Defaults to 15. This was formerly the "rpp" parameter in the old Search API.

$until

\string[optional]

Returns tweets generated before the given date. Date should be formatted as YYYY-MM-DD. Keep in mind that the search index may not go back as far as the date you specify here.

$sinceId

\string[optional]

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.

$maxId

\string[optional]

Returns results with an ID less than (that is, older than) or equal to the specified ID.

$includeEntities

\bool[optional]

The entities node will be disincluded when set to false.

Response

array

Set the consumer key

setConsumerKey(string $key) 

Arguments

$key

string

The consumer key to use.

Set the consumer secret

setConsumerSecret(string $secret) 

Arguments

$secret

string

The consumer secret to use.

Set the oAuth-token

setOAuthToken(string $token) 

Arguments

$token

string

The token to use.

Set the oAuth-secret

setOAuthTokenSecret(string $secret) 

Arguments

$secret

string

The secret to use.

Set the response type

setReturnAsArray(boolean $value) 

Arguments

$value

boolean

True for array and false for object

Set the timeout

setTimeOut(integer $seconds) 

Arguments

$seconds

integer

The timeout in seconds.

Get the useragent that will be used. Our version will be prepended to yours.

setUserAgent(string $userAgent) 

It will look like: "PHP Twitter/ "

Arguments

$userAgent

string

Your user-agent, it should look like /.

Not implemented yet

site() 

Destroys the status specified by the required ID parameter. The authenticating user must be the author of the specified status. Returns the destroyed status if successful.

statusesDestroy(string $id, \bool[optional] $trimUser = null) : array

Arguments

$id

string

The numerical ID of the desired status.

$trimUser

\bool[optional]

When set to true, each tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object.

Response

array

Not implemented yet

statusesFilter() 

Not implemented yet

statusesFirehose() 

Returns the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the user's they follow. This is the same timeline seen by a user when they login to twitter.com.

statusesHomeTimeline(\int[optional] $count = null, \string[optional] $sinceId = null, \string[optional] $maxId = null, \bool[optional] $trimUser = null, \bool[optional] $excludeReplies = null, \bool[optional] $contributorDetails = null, \bool[optional] $includeEntities = null) : array

This method is identical to statusesFriendsTimeline, except that this method always includes retweets.

Arguments

$count

\int[optional]

Specifies the number of records to retrieve. Must be less than or equal to 200. Defaults to 20.

$sinceId

\string[optional]

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.

$maxId

\string[optional]

Returns results with an ID less than (that is, older than) or equal to the specified ID.

$trimUser

\bool[optional]

When set to true, each tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object.

$excludeReplies

\bool[optional]

This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count tweets — this is because the count parameter retrieves that many tweets before filtering out retweets and replies.

$contributorDetails

\bool[optional]

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.

$includeEntities

\bool[optional]

The entities node will be disincluded when set to false.

Response

array

Returns the 20 most recent mentions (tweets containing a users's @screen_name) for the authenticating user.

statusesMentionsTimeline(\int[optional] $count = null, \string[optional] $sinceId = null, \string[optional] $maxId = null, \bool[optional] $trimUser = null, \bool[optional] $contributorDetails = null, \bool[optional] $includeEntities = null) : array

The timeline returned is the equivalent of the one seen when you view your mentions on twitter.com. This method can only return up to 800 tweets.

Arguments

$count

\int[optional]

Specifies the number of tweets to try and retrieve, up to a maximum of 200. The value of count is best thought of as a limit to the number of tweets to return because suspended or deleted content is removed after the count has been applied. We include retweets in the count, even if include_rts is not supplied.

$sinceId

\string[optional]

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.

$maxId

\string[optional]

Returns results with an ID less than (that is, older than) or equal to the specified ID.

$trimUser

\bool[optional]

When set to true, each tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object.

$contributorDetails

\bool[optional]

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.

$includeEntities

\bool[optional]

The entities node will be disincluded when set to false.

Response

array

statusesOEmbed

statusesOEmbed(\string[optional] $id = null, \string[optional] $url = null, \int[optional] $maxwidth = null, \bool[optional] $hideMedia = null, \bool[optional] $hideThread = null, \bool[optional] $omitScript = null, \string[optional] $align = null, \string[optional] $related = null, \string[optional] $lang = null) : array

Arguments

$id

\string[optional]

The Tweet/status ID to return embed code for.

$url

\string[optional]

The URL of the Tweet/status to be embedded.

$maxwidth

\int[optional]

The maximum width in pixels that the embed should be rendered at. This value is constrained to be between 250 and 550 pixels. Note that Twitter does not support the oEmbed maxheight parameter. Tweets are fundamentally text, and are therefore of unpredictable height that cannot be scaled like an image or video. Relatedly, the oEmbed response will not provide a value for height. Implementations that need consistent heights for Tweets should refer to the hide_thread and hide_media parameters below.

$hideMedia

\bool[optional]

Specifies whether the embedded Tweet should automatically expand images which were uploaded via POST statuses/update_with_media. When set to true images will not be expanded. Defaults to false.

$hideThread

\bool[optional]

Specifies whether the embedded Tweet should automatically show the original message in the case that the embedded Tweet is a reply. When set to true the original Tweet will not be shown. Defaults to false.

$omitScript

\bool[optional]

Specifies whether the embedded Tweet HTML should include a