API Documentation

Zend/Service/Twitter.php

Show: inherited
Table of Contents

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Service  
Subpackage
Twitter  
Version
$Id: Twitter.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Service_Twitter

Package: Zend\Service\Twitter

Parent(s)
\Zend_Rest_Client < \Zend_Service_Abstract
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

Constant  STATUS_MAX_CHARACTERS = 246

246 is the current limit for a status message, 140 characters are displayed initially, with the remainder linked from the web UI or client. The limit is applied to a html encoded UTF-8 string (i.e. entities are counted in the limit which may appear unusual but is a security measure).

This should be reviewed in the future...

Constant  OAUTH_BASE_URI = 'http://twitter.com/oauth'

OAuth Endpoint

Properties

Propertyprotected\Zend_Http_CookieJar  $_cookieJar= ''

Details
Type
\Zend_Http_CookieJar
Propertyprotectedstring  $_dateFormat= ''D, d M Y H:i:s T''

Date format for 'since' strings

Default value'D, d M Y H:i:s T'Details
Type
string
Propertyprotected\Zend_Http_Client  $_localHttpClient= 'null'

Local HTTP Client cloned from statically set client

Default valuenullDetails
Type
\Zend_Http_Client
Propertyprotectedstring  $_methodType= ''

Current method type (for method proxying)

Details
Type
string
Propertyprotectedarray  $_methodTypes= 'array( 'status''

Types of API methods

Default valuearray( 'status'Details
Type
array
Propertyprotected\Zend_Oauth_Consumer  $_oauthConsumer= 'null'

Zend_Oauth Consumer

Default valuenullDetails
Type
\Zend_Oauth_Consumer
Propertyprotectedarray  $_options= 'array()'

Options passed to constructor

Default valuearray()Details
Type
array
Propertyprotectedstring  $_username= ''

Username

Details
Type
string

Methods

methodpublic__call( string $method, array $params ) : mixed

Method overloading

Parameters
Name Type Description
$method string
$params array
Returns
Type Description
mixed
Throws
Exception Description
\Zend_Service_Twitter_Exception if unable to find method
methodpublic__construct( array $options = null,  $consumer = null ) : void

Constructor

Parameters
Name Type Description
$options array

Optional options array

$consumer
methodpublic__get( string $type ) : \Zend_Service_Twitter

Proxy service methods

Parameters
Name Type Description
$type string
Returns
Type Description
\Zend_Service_Twitter
Throws
Exception Description
\Zend_Service_Twitter_Exception If method not in method types list
methodprotected_get( string $path, array $query = null ) : \Zend_Http_Response

Performs an HTTP GET request to the $path.

Parameters
Name Type Description
$path string
$query array

Array of GET parameters

Returns
Type Description
\Zend_Http_Response
Throws
Exception Description
\Zend_Http_Client_Exception
methodprotected_init( ) : void

Initialize HTTP authentication

methodprotected_performPost( mixed $method, mixed $data = null ) : \Zend_Http_Response

Perform a POST or PUT

Performs a POST or PUT request. Any data provided is set in the HTTP client. String data is pushed in as raw POST data; array or object data is pushed in as POST parameters.

Parameters
Name Type Description
$method mixed
$data mixed
Returns
Type Description
\Zend_Http_Response
methodprotected_post( string $path, mixed $data = null ) : \Zend_Http_Response

Performs an HTTP POST request to $path.

Parameters
Name Type Description
$path string
$data mixed

Raw data to send

Returns
Type Description
\Zend_Http_Response
Throws
Exception Description
\Zend_Http_Client_Exception
methodprotected_prepare( string $path ) : void

Call a remote REST web service URI and return the Zend_Http_Response object

Parameters
Name Type Description
$path string

The path to append to the URI

Throws
Exception Description
\Zend_Rest_Client_Exception
methodprotected_setDate( int|string $value ) : void

Set date header

Parameters
Name Type Description
$value int|string
Details
Deprecated
Not supported by Twitter since April 08, 2009  
methodprotected_validInteger( mixed $int ) : integer

Protected function to validate that the integer is valid or return a 0

Parameters
Name Type Description
$int mixed
Returns
Type Description
integer
methodprotected_validateScreenName( string $name ) : string

Validate a screen name using Twitter rules

Parameters
Name Type Description
$name string
Returns
Type Description
string
Throws
Exception Description
\Zend_Service_Twitter_Exception
methodpublicaccountEndSession( ) : true

End current session

Returns
Type Description
true
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicaccountRateLimitStatus( ) : \Zend_Rest_Client_Result

Returns the number of api requests you have left per hour.

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicaccountVerifyCredentials( ) : \Zend_Rest_Client_Result

Verify Account Credentials

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicblockBlocking( integer $page = 1, boolean $returnUserIds = false ) : \Zend_Rest_Client_Result

Returns an array of user objects that the authenticating user is blocking

Parameters
Name Type Description
$page integer

Optional. Specifies the page number of the results beginning at 1. A single page contains 20 ids.

$returnUserIds boolean

Optional. Returns only the userid's instead of the whole user object

Returns
Type Description
\Zend_Rest_Client_Result
methodpublicblockCreate( integer|string $id ) : \Zend_Rest_Client_Result

Blocks the user specified in the ID parameter as the authenticating user.

Destroys a friendship to the blocked user if it exists.

Parameters
Name Type Description
$id integer|string

The ID or screen name of a user to block.

Returns
Type Description
\Zend_Rest_Client_Result
methodpublicblockDestroy( integer|string $id ) : \Zend_Rest_Client_Result

Un-blocks the user specified in the ID parameter for the authenticating user

Parameters
Name Type Description
$id integer|string

The ID or screen_name of the user to un-block.

Returns
Type Description
\Zend_Rest_Client_Result
methodpublicblockExists( string|integer $id, boolean $returnResult = false ) : Boolean|\Zend_Rest_Client_Result

Returns if the authenticating user is blocking a target user.

Parameters
Name Type Description
$id string|integer

The ID or screen_name of the potentially blocked user.

$returnResult boolean

Instead of returning a boolean return the rest response from twitter

Returns
Type Description
Boolean|\Zend_Rest_Client_Result
methodpublicdirectMessageDestroy( int $id ) : \Zend_Rest_Client_Result

Destroy a direct message

Parameters
Name Type Description
$id int

ID of message to destroy

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicdirectMessageMessages( array $params = array() ) : \Zend_Rest_Client_Result

Retrieve direct messages for the current user

$params may include one or more of the following keys - since_id: return statuses only greater than the one specified - page: return page X of results

Parameters
Name Type Description
$params array
Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicdirectMessageNew( int|string $user, string $text ) : \Zend_Rest_Client_Result

Send a direct message to a user

Parameters
Name Type Description
$user int|string

User to whom to send message

$text string

Message to send to user

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Service_Twitter_Exception if message is too short or too long
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicdirectMessageSent( array $params = array() ) : \Zend_Rest_Client_Result

Retrieve list of direct messages sent by current user

$params may include one or more of the following keys - since_id: return statuses only greater than the one specified - page: return page X of results

Parameters
Name Type Description
$params array
Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicfavoriteCreate( int $id ) : \Zend_Rest_Client_Result

Mark a status as a favorite

Parameters
Name Type Description
$id int

Status ID you want to mark as a favorite

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicfavoriteDestroy( int $id ) : \Zend_Rest_Client_Result

Remove a favorite

Parameters
Name Type Description
$id int

Status ID you want to de-list as a favorite

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicfavoriteFavorites( array $params = array() ) : \Zend_Rest_Client_Result

Fetch favorites

$params may contain one or more of the following: - 'id': Id of a user for whom to fetch favorites - 'page': Retrieve a different page of resuls

Parameters
Name Type Description
$params array
Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicfriendshipCreate( int|string $id ) : \Zend_Rest_Client_Result

Create friendship

Parameters
Name Type Description
$id int|string

User ID or name of new friend

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicfriendshipDestroy( int|string $id ) : \Zend_Rest_Client_Result

Destroy friendship

Parameters
Name Type Description
$id int|string

User ID or name of friend to remove

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicfriendshipExists( int|string $id ) : \Zend_Rest_Client_result

Friendship exists

Parameters
Name Type Description
$id int|string

User ID or name of friend to see if they are your friend

Returns
Type Description
\Zend_Rest_Client_result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicgetLocalHttpClient( ) : \Zend_Http_Client

Get the local HTTP client as distinct from the static HTTP client inherited from Zend_Rest_Client

Returns
Type Description
\Zend_Http_Client
methodpublicgetUsername( ) : string

Retrieve username

Returns
Type Description
string
methodpublicisAuthorised( ) : bool

Checks for an authorised state

Returns
Type Description
bool
methodpublicsetLocalHttpClient( \Zend_Http_Client $client ) : \Zend_Service_Twitter

Set local HTTP client as distinct from the static HTTP client as inherited from Zend_Rest_Client.

Parameters
Name Type Description
$client \Zend_Http_Client
Returns
Type Description
\Zend_Service_Twitter
Details
Fluent
This method is part of a fluent interface and will return the same instance  
methodpublicsetUsername( string $value ) : \Zend_Service_Twitter

Set username

Parameters
Name Type Description
$value string
Returns
Type Description
\Zend_Service_Twitter
methodpublicstatusDestroy( int $id ) : \Zend_Rest_Client_Result

Destroy a status message

Parameters
Name Type Description
$id int

ID of status to destroy

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicstatusFriendsTimeline( array $params = array() ) : void

Friend Timeline Status

$params may include one or more of the following keys - id: ID of a friend whose timeline you wish to receive - count: how many statuses to return - since_id: return results only after the specific tweet - page: return page X of results

Parameters
Name Type Description
$params array
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicstatusPublicTimeline( ) : \Zend_Rest_Client_Result

Public Timeline status

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicstatusReplies(  $params = array() ) : \Zend_Rest_Client_Result

Get status replies

$params may include one or more of the following keys - since_id: return results only after the specified tweet id - page: return page X of results

Parameters
Name Type Description
$params
Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicstatusShow( int $id ) : \Zend_Rest_Client_Result

Show a single status

Parameters
Name Type Description
$id int

Id of status to show

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicstatusUpdate( string $status,  $inReplyToStatusId = null ) : \Zend_Rest_Client_Result

Update user's current status

Parameters
Name Type Description
$status string
$inReplyToStatusId
Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
\Zend_Service_Twitter_Exception if message is too short or too long
methodpublicstatusUserTimeline(  $params = array() ) : \Zend_Rest_Client_Result

User Timeline status

$params may include one or more of the following keys - id: ID of a friend whose timeline you wish to receive - since_id: return results only after the tweet id specified - page: return page X of results - count: how many statuses to return - max_id: returns only statuses with an ID less than or equal to the specified ID - user_id: specifies the ID of the user for whom to return the user_timeline - screen_name: specfies the screen name of the user for whom to return the user_timeline - include_rts: whether or not to return retweets - trim_user: whether to return just the user ID or a full user object; omit to return full object - include_entities: whether or not to return entities nodes with tweet metadata

Parameters
Name Type Description
$params
Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicuserFollowers( bool $lite = false ) : \Zend_Rest_Client_Result

User Followers

Parameters
Name Type Description
$lite bool

If true, prevents inline inclusion of current status for followers; defaults to false

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicuserFriends(  $params = array() ) : \Zend_Rest_Client_Result

User friends

Parameters
Name Type Description
$params
Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
methodpublicuserShow( int|string $id ) : \Zend_Rest_Client_Result

Show extended information on a user

Parameters
Name Type Description
$id int|string

User ID or name

Returns
Type Description
\Zend_Rest_Client_Result
Throws
Exception Description
\Zend_Http_Client_Exception if HTTP request fails or times out
Documentation was generated by DocBlox 0.15.1.