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
= 246Properties

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) : mixedMethod 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) : voidConstructor
| Name | Type | Description |
|---|---|---|
| $options | null | array | \Zend_Config | |
| $consumer | null | \Zend_Oauth_Consumer | |
| $httpClient | null | \Zend_Http_Client |

__get(string $type) : \TwitterProxy service methods
| Name | Type | Description |
|---|---|---|
| $type | string |
| Type | Description |
|---|---|
| Exception | Description |
|---|---|
| \Exception\DomainException | If method not in method types list |

accountVerifyCredentials() : \Zend_Service_Twitter_ResponseVerify 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_ResponseReturns 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_ResponseBlocks 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_ResponseUn-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_ResponseReturns 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_ResponseReturns 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) : arrayCreate a parameter representing the user
| Name | Type | Description |
|---|---|---|
| $id | int | string | |
| $params | array |
| Type | Description |
|---|---|
| array |

directMessagesDestroy(int $id) : \Zend_Service_Twitter_ResponseDestroy 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_ResponseRetrieve 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_ResponseSend 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_ResponseRetrieve 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_ResponseMark 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_ResponseRemove 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_ResponseFetch 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_ResponseCreate 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_ResponseDestroy 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_ResponsePerforms 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_ClientGet the HTTP client
| Type | Description |
|---|---|
| \Zend_Http_Client |

init() : voidInitialize HTTP authentication
| Exception | Description |
|---|---|
| \Exception\DomainException | if unauthorised |

performPost(mixed $method, mixed $data, $client) : \Zend_Http_ResponsePerform 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_ResponsePerforms 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) : voidCall 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_ResponseSearch 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_TwitterSet 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_TwitterSet 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_ResponseDestroy 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_ResponseFriend 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_ResponseGet 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_ResponsePublic 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_ResponseShow 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_ResponseUpdate 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_ResponseUser 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_ResponseSearch 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_ResponseShow 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) : integerProtected 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) : stringValidate a screen name using Twitter rules
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \Exception\InvalidArgumentException |