Service/Twitter.php
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Service
- Subpackage
- Version
- $Id$
\Zend_Service_Twitter
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
STATUS_MAX_CHARACTERS
= 246
Properties
string $dateFormat = 'D, d M Y H:i:s T'
'D, d M Y H:i:s T'
Details- Type
- string
array $methodTypes = array('account', 'application', 'blocks', 'directmessages', 'favorites', 'friendships', 'search', 'statuses', 'users')
array('account', 'application', 'blocks', 'directmessages', 'favorites', 'friendships', 'search', 'statuses', 'users')
Details- Type
- array
Methods
__call(string $method, array $params) : mixed
Method overloading
Name | Type | Description |
---|---|---|
$method | string | |
$params | array |
Type | Description |
---|---|
mixed |
Exception | Description |
---|---|
\Exception\BadMethodCallException | if unable to find method |
__construct(null | array | \Zend_Config $options = null, null | \Zend_Oauth_Consumer $consumer = null, null | \Zend_Http_Client $httpClient = null) : void
Constructor
Name | Type | Description |
---|---|---|
$options | null | array | \Zend_Config | |
$consumer | null | \Zend_Oauth_Consumer | |
$httpClient | null | \Zend_Http_Client |
__get(string $type) : \Twitter
Proxy service methods
Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
Exception | Description |
---|---|
\Exception\DomainException | If method not in method types list |
accountVerifyCredentials() : \Zend_Service_Twitter_Response
Verify Account Credentials
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
applicationRateLimitStatus() : \Zend_Service_Twitter_Response
Returns the number of api requests you have left per hour.
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
- Todo
- Have a separate payload object to represent rate limits
blocksCreate(integer | string $id) : \Zend_Service_Twitter_Response
Blocks the user specified in the ID parameter as the authenticating user.
Name | Type | Description |
---|---|---|
$id | integer | string | The ID or screen name of a user to block. |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Exception\DomainException | if unable to decode JSON payload |
blocksDestroy(integer | string $id) : \Zend_Service_Twitter_Response
Un-blocks the user specified in the ID parameter for the authenticating user
Name | Type | Description |
---|---|---|
$id | integer | string | The ID or screen_name of the user to un-block. |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Exception\DomainException | if unable to decode JSON payload |
blocksIds(integer $cursor = -1) : \Zend_Service_Twitter_Response
Returns an array of user ids that the authenticating user is blocking
Name | Type | Description |
---|---|---|
$cursor | integer | Optional. Specifies the cursor position at which to begin listing ids; defaults to first "page" of results. |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Exception\DomainException | if unable to decode JSON payload |
blocksList(integer $cursor = -1) : \Zend_Service_Twitter_Response
Returns an array of user objects that the authenticating user is blocking
Name | Type | Description |
---|---|---|
$cursor | integer | Optional. Specifies the cursor position at which to begin listing ids; defaults to first "page" of results. |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Exception\DomainException | if unable to decode JSON payload |
createUserParameter(int | string $id, array $params) : array
Create a parameter representing the user
Name | Type | Description |
---|---|---|
$id | int | string | |
$params | array |
Type | Description |
---|---|
array |
directMessagesDestroy(int $id) : \Zend_Service_Twitter_Response
Destroy a direct message
Name | Type | Description |
---|---|---|
$id | int | ID of message to destroy |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
directMessagesMessages(array $options = array()) : \Zend_Service_Twitter_Response
Retrieve direct messages for the current user
Name | Type | Description |
---|---|---|
$options | array |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
directMessagesNew(int | string $user, string $text) : \Zend_Service_Twitter_Response
Send a direct message to a user
Name | Type | Description |
---|---|---|
$user | int | string | User to whom to send message |
$text | string | Message to send to user |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Exception\InvalidArgumentException | if message is empty |
\Exception\OutOfRangeException | if message is too long |
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
directMessagesSent(array $options = array()) : \Zend_Service_Twitter_Response
Retrieve list of direct messages sent by current user
Name | Type | Description |
---|---|---|
$options | array |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
favoritesCreate(int $id) : \Zend_Service_Twitter_Response
Mark a status as a favorite
Name | Type | Description |
---|---|---|
$id | int | Status ID you want to mark as a favorite |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
favoritesDestroy(int $id) : \Zend_Service_Twitter_Response
Remove a favorite
Name | Type | Description |
---|---|---|
$id | int | Status ID you want to de-list as a favorite |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
favoritesList( $options = array()) : \Zend_Service_Twitter_Response
Fetch favorites
Name | Type | Description |
---|---|---|
$options |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
friendshipsCreate(int | string $id, array $params = array()) : \Zend_Service_Twitter_Response
Create friendship
Name | Type | Description |
---|---|---|
$id | int | string | User ID or name of new friend |
$params | array | Additional parameters to pass |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
friendshipsDestroy(int | string $id) : \Zend_Service_Twitter_Response
Destroy friendship
Name | Type | Description |
---|---|---|
$id | int | string | User ID or name of friend to remove |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
get(string $path, array $query = array()) : \Zend_Http_Response
Performs an HTTP GET request to the $path.
Name | Type | Description |
---|---|---|
$path | string | |
$query | array | Array of GET parameters |
Type | Description |
---|---|
\Zend_Http_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception |
getHttpClient() : \Zend_Http_Client
Get the HTTP client
Type | Description |
---|---|
\Zend_Http_Client |
init() : void
Initialize HTTP authentication
Exception | Description |
---|---|
\Exception\DomainException | if unauthorised |
performPost(mixed $method, mixed $data, $client) : \Zend_Http_Response
Perform a POST or PUT
Name | Type | Description |
---|---|---|
$method | mixed | |
$data | mixed | |
$client |
Type | Description |
---|---|
\Zend_Http_Response |
post(string $path, mixed $data = null) : \Zend_Http_Response
Performs an HTTP POST request to $path.
Name | Type | Description |
---|---|---|
$path | string | |
$data | mixed | Raw data to send |
Type | Description |
---|---|
\Zend_Http_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception |
prepare(string $path, \Zend_Http_Client $client) : void
Call a remote REST web service URI
Name | Type | Description |
---|---|---|
$path | string | The path to append to the URI |
$client | \Zend_Http_Client |
Exception | Description |
---|---|
\Zend_Http_Client_Exception |
searchTweets(string $query, array $options = array()) : \Zend_Service_Twitter_Response
Search tweets
Name | Type | Description |
---|---|---|
$query | string | |
$options | array |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
setHttpClient(\Zend_Http_Client $client) : \Zend_Service_Twitter
Set HTTP client
Name | Type | Description |
---|---|---|
$client | \Zend_Http_Client |
Type | Description |
---|---|
\Zend_Service_Twitter |
- Fluent
- This method is part of a fluent interface and will return the same instance
setUsername(string $value) : \Zend_Service_Twitter
Set username
Name | Type | Description |
---|---|---|
$value | string |
Type | Description |
---|---|
\Zend_Service_Twitter |
- Fluent
- This method is part of a fluent interface and will return the same instance
statusesDestroy(int $id) : \Zend_Service_Twitter_Response
Destroy a status message
Name | Type | Description |
---|---|---|
$id | int | ID of status to destroy |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
statusesHomeTimeline( $options = array()) : \Zend_Service_Twitter_Response
Friend Timeline Status
Name | Type | Description |
---|---|---|
$options |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
statusesMentionsTimeline(array $options = array()) : \Zend_Service_Twitter_Response
Get status replies
Name | Type | Description |
---|---|---|
$options | array |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
statusesSample() : \Zend_Service_Twitter_Response
Public Timeline status
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
statusesShow(int $id) : \Zend_Service_Twitter_Response
Show a single status
Name | Type | Description |
---|---|---|
$id | int | Id of status to show |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
statusesUpdate(string $status, null | int $inReplyToStatusId = null) : \Zend_Service_Twitter_Response
Update user's current status
Name | Type | Description |
---|---|---|
$status | string | |
$inReplyToStatusId | null | int |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\OutOfRangeException | if message is too long |
\Exception\InvalidArgumentException | if message is empty |
\Exception\DomainException | if unable to decode JSON payload |
- Todo
- Support additional parameters supported by statuses/update endpoint
statusesUserTimeline( $options = array()) : \Zend_Service_Twitter_Response
User Timeline status
Name | Type | Description |
---|---|---|
$options |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
usersSearch(string $query, array $options = array()) : \Zend_Service_Twitter_Response
Search users
Name | Type | Description |
---|---|---|
$query | string | |
$options | array |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
usersShow(int | string $id) : \Zend_Service_Twitter_Response
Show extended information on a user
Name | Type | Description |
---|---|---|
$id | int | string | User ID or name |
Type | Description |
---|---|
\Zend_Service_Twitter_Response |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
\Exception\DomainException | if unable to decode JSON payload |
validInteger( $int) : integer
Protected function to validate that the integer is valid or return a 0
Name | Type | Description |
---|---|---|
$int |
Type | Description |
---|---|
integer |
Exception | Description |
---|---|
\Zend_Http_Client_Exception | if HTTP request fails or times out |
validateScreenName(string $name) : string
Validate a screen name using Twitter rules
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Exception\InvalidArgumentException |