Twitter class
Possible Methods
- __construct
- setTimeOut
- setUserAgent
- getPublicTimeline
- getFriendsTimeline
- getUserTimeline
- getMentionsReplies
- getStatus
- updateStatus
- deleteStatus
- getUser
- getFriends
- getFollowers
- getDirectMessages
- getSentDirectMessages
- sendDirectMessage
- deleteDirectMessage
- createFriendship
- deleteFriendship
- existsFriendship
- getFriendship
- getFriendIds
- getFollowerIds
- verifyCredentials
- getRateLimitStatus
- endSession
- updateDeliveryDevice
- updateProfileColors
- updateProfileImage
- updateProfileBackgroundImage
- updateProfile
- getFavorites
- createFavorite
- deleteFavorite
- follow
- unfollow
- createBlock
- deleteBlock
- existsBlock
- getBlocked
- getBlockedIds
- test
__construct
Default constructor
Parameters
- username string (optional)
- The username for an authenticating user
- password string (optional)
- The password for an authenticating user
Return
void
Example
<?php
// require class
require_once 'twitter.php';
// create instance
$twitter = new Twitter('<your-login>', '<your-password>');
?>
setTimeOut
Set the timeout
Parameters
- seconds int
- The timeout in seconds
Return
void
setUserAgent
Get the useragent that will be used. Our version will be prepended to yours.
It will look like: "PHP Akismet/<version> <your-user-agent>"
Parameters
- userAgent string
- Your user-agent, it should look like <app-name>/<app-version>
Return
void
getPublicTimeline
Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
Note that the public timeline is cached for 60 seconds so requesting it more often than that is a waste of resources.
Return
array
getFriendsTimeline
Returns the 20 most recent statuses posted by the authenticating user and that user's friends.
This is the equivalent of /home on the Web.
Parameters
- sinceId string (optional)
- Returns only statuses with an id greater than (that is, more recent than) the specified $sinceId.
- maxId string (optional)
- Returns only statuses with an ID less than (that is, older than) or equal to the specified $maxId.
- count int (optional)
- Specifies the number of statuses to retrieve. May not be greater than 200.
- page int (optional)
Return
array
getUserTimeline
Returns the 20 most recent statuses posted from the authenticating user. It's also possible to request another user's timeline via the id parameter below.
This is the equivalent of the Web /archive page for your own user, or the profile page for a third party.
Parameters
- id string (optional)
- Specifies the id or screen name of the user for whom to return the friends_timeline.
- sinceId string (optional)
- Returns only statuses with an id greater than (that is, more recent than) the specified $sinceId.
- maxId string (optional)
- Returns only statuses with an ID less than (that is, older than) or equal to the specified $maxId.
- count int (optional)
- Specifies the number of statuses to retrieve. May not be greater than 200.
- page int (optional)
- Specifies the page or results to retrieve.
Return
array
getMentionsReplies
Returns the 20 most recent mentions (status containing @username) for the authenticating user.
Parameters
- sinceId string (optional)
- Returns only statuses with an id greater than (that is, more recent than) the specified $sinceId.
- maxId string (optional)
- Returns only statuses with an ID less than (that is, older than) or equal to the specified $maxId.
- count int (optional)
- Specifies the number of statuses to retrieve. May not be greater than 200.
- page int (optional)
- Specifies the page or results to retrieve.
Return
array
getStatus
Returns a single status, specified by the id parameter below.
Parameters
- id int
- The numerical id of the status you're trying to retrieve.
Return
array
updateStatus
Updates the authenticating user's status.
A status update with text identical to the authenticating user's current status will be ignored.
Parameters
- status string
- The text of your status update. Should not be more than 140 characters.
- inReplyToId int (optional)
- The id of an existing status that the status to be posted is in reply to.
Return
array
deleteStatus
Destroys the status specified by the required $id parameter.
The authenticating user must be the author of the specified status.
Parameters
- id int (optional)
Return
array
getUser
Returns extended information of a given user, specified by id or screen name.
This information includes design settings, so third party developers can theme their widgets according to a given user's preferences.
You must be properly authenticated to request the page of a protected user.
Parameters
- id string
- The id or screen name of a user.
Return
array
getFriends
Returns up to 100 of the authenticating user's friends who have most recently updated.
It's also possible to request another user's recent friends list via the $id parameter.
Parameters
- id string (optional)
- The id or screen name of the user for whom to request a list of friends.
- cursor
Return
array
getFollowers
Returns the authenticating user's followers.
Parameters
- id string (optional)
- The id or screen name of the user for whom to request a list of followers.
- page int (optional)
Return
array
getDirectMessages
Returns a list of the 20 most recent direct messages sent to the authenticating user.
Parameters
- sinceId string (optional)
- Returns only direct messages with an id greater than (that is, more recent than) the specified $sinceId.
- maxId string (optional)
- Returns only statuses with an ID less than (that is, older than) or equal to the specified $maxId.
- count int (optional)
- Specifies the number of statuses to retrieve. May not be greater than 200.
- page int (optional)
Return
array
getSentDirectMessages
Returns a list of the 20 most recent direct messages sent by the authenticating user.
Parameters
- sinceId string (optional)
- Returns only sent direct messages with an id greater than (that is, more recent than) the specified $sinceId.
- maxId string (optional)
- Returns only statuses with an ID less than (that is, older than) or equal to the specified $maxId.
- count int[optiona]
- Specifies the number of direct messages to retrieve. May not be greater than 200.
- page int (optional)
Return
array
sendDirectMessage
Sends a new direct message to the specified user from the authenticating user.
Parameters
- id string
- The id or screen name of the recipient user.
- text string
- The text of your direct message. Keep it under 140 characters.
Return
array
deleteDirectMessage
Destroys the direct message.
The authenticating user must be the recipient of the specified direct message.
Parameters
- id string
Return
array
createFriendship
Befriends the user specified in the id parameter as the authenticating user.
Parameters
- id string
- The id or screen name of the user to befriend.
- follow bool (optional)
- Enable notifications for the target user in addition to becoming friends.
Return
array
deleteFriendship
Discontinues friendship with the user.
Parameters
- id string
Return
array
existsFriendship
Tests if a friendship exists between two users.
Parameters
- id string
- The id or screen_name of the first user to test friendship for.
- friendId string
- The id or screen_name of the second user to test friendship for.
Return
bool
getFriendship
Returns detailed information about the relationship between two users.
Parameters
- id string
- The id or screen name of the subject user.
- friendId string
- The id or screen name of the target user.
Return
array
getFriendIds
Returns an array of numeric IDs for every user the specified user is following.
Parameters
- id string (optional)
- The id or screen name of the user for whom to request a list of friends.
- page int (optional)
- Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned. (Please note that the result set isn't guaranteed to be 5000 every time as suspended users will be filtered out.)
Return
array
getFollowerIds
Returns an array of numeric IDs for every user following the specified user.
Parameters
- id string (optional)
- The id or screen name of the user to retrieve the friends ID list for.
- page int (optional)
- Specifies the page number of the results beginning at 1. A single page contains 5000 ids. This is recommended for users with large ID lists. If not provided all ids are returned. (Please note that the result set isn't guaranteed to be 5000 every time as suspended users will be filtered out.)
Return
array
verifyCredentials
Verifies your credentials
Use this method to test if supplied user credentials are valid.
Return
bool
getRateLimitStatus
Returns the remaining number of API requests available to the requesting user before the API limit is reached for the current hour.
Return
array
endSession
Ends the session of the authenticating user, returning a null cookie.
Use this method to sign users out of client-facing applications like widgets.
Return
void
updateDeliveryDevice
Sets which device Twitter delivers updates to for the authenticating user.
Sending none as the device parameter will disable IM or SMS updates.
Parameters
- device string
- Must be one of: sms, im, none.
Return
array
updateProfileColors
Sets one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com.
Only the parameters specified will be updated.
Parameters
- backgroundColor string[optiona]
- textColor string[optiona]
- linkColor string[optiona]
- sidebarBackgroundColor string[optiona]
- sidebarBorderColor string[optiona]
Return
array
updateProfileImage
Updates the authenticating user's profile image.
Expects raw multipart data, not a URL to an image.
@remark not implemented yet, feel free to code
Parameters
- image string
Return
void
updateProfileBackgroundImage
Updates the authenticating user's profile background image.
Expects raw multipart data, not a URL to an image.
@remark not implemented yet, feel free to code
Parameters
- image string
Return
void
updateProfile
Sets values that users are able to set under the "Account" tab of their settings page.
Only the parameters specified will be updated.
Parameters
- name string (optional)
- email string (optional)
- url string (optional)
- location string (optional)
- description string (optional)
Return
array
getFavorites
Returns the 20 most recent favorite statuses for the authenticating user or user specified by the $id parameter
Parameters
- id string (optional)
- The id or screen name of the user for whom to request a list of favorite statuses.
- page int (optional)
Return
array
createFavorite
Favorites the status specified in the id parameter as the authenticating user.
Parameters
- id string
Return
array
deleteFavorite
Un-favorites the status specified in the id parameter as the authenticating user.
Parameters
- id string
Return
array
follow
Enables notifications for updates from the specified user to the authenticating user.
This method requires the authenticated user to already be friends with the specified user otherwise the error "there was a problem following the specified user" will be returned.
Parameters
- id string
Return
void
unfollow
Disables notifications for updates from the specified user to the authenticating user.
This method requires the authenticated user to already be friends with the specified user otherwise the error "there was a problem following the specified user" will be returned.
Parameters
- id string
Return
void
createBlock
Blocks the user specified in the id parameter as the authenticating user.
Parameters
- id string
Return
void
deleteBlock
Un-blocks the user specified in the id parameter as the authenticating user.
Parameters
- id string
Return
void
existsBlock
Returns if the authenticating user is blocking a target user.
Parameters
- id string
- The id or screen_name of the potentially blocked user.
Return
bool
getBlocked
Returns an array of user that the authenticating user is blocking.
Parameters
- page int (optional)
- Specifies the page number of the results beginning at 1. A single page contains 20 ids.
Return
array
getBlockedIds
Returns an array of numeric user ids the authenticating user is blocking.
Return
array
test
Test the connection to Twitter
Return
bool