PHP Class TTools\App

Mostra file Open project: ttools/ttools

Public Methods

Method Description
__construct ( array $config, TTools\Provider\StorageProviderInterface $sp = null, TTools\Provider\RequestProviderInterface $rp = null )
destroy ( string $tweet_id ) : array | mixed Destroy a tweet
get ( $path, array $params = [] ) : array Performs a GET request to the Twitter API
getCredentials ( ) : array Get logged user profile
getCurrentUser ( ) : User Gets the current logged user, if any.
getFavorites ( integer $limit = 10 ) : array Gets current user favorites
getLastReqInfo ( ) : array Gets information about the last request.
getLoggedUser ( ) : User Returns a User object with ArrayAccess. Returns null if there's no logged user.
getLoginUrl ( string $callbackUrl = null ) : string
getMentions ( integer $limit = 10 ) : array Gets mentions for the current user
getProfile ( array $params = null ) : array Gets a user profile. If you want to get another user's profile, you just need to provide an array with either the 'user_id' or the 'screen_name' .
getRemainingCalls ( ) : array Returns information about the API usage and how many calls you have left.
getState ( ) : integer Returns current state
getTimeline ( integer $limit = 10 ) : array Gets the home timeline for current authenticated user
getTweet ( string $tweet_id ) : array Gets a specific Tweet
getUser ( ) : User Retrieves the Twitter User. If there's no logged user yet, it will check if the user is coming back from the Twitter Auth page and retrieve its tokens.
getUserTimeline ( null $user_id = null, null $screen_name = null, integer $limit = 10 ) : array Gets a user timeline (tweets posted by a user). Defaults to the current user timeline
getUserTokens ( ) : array
isLogged ( ) : integer
linkify ( string $message ) : string Renders links, hash tags, and account mentions of a Tweet message as clickable links
logout ( ) : mixed
post ( $path, $params, boolean $multipart = false ) : array Performs a POST request to the Twitter API
update ( string $message, string $in_reply_to = null, $media = [] ) : array Post a tweet
updateWithMedia ( string $image, string $message, string $in_reply_to = null ) : array Post a tweet with an image embedded - to keep backwards compatibility
uploadMedia ( string $image ) : array Uploads media to uploads.twitter.com to be embedded in tweets

Private Methods

Method Description
setState ( $state ) Internal - Sets current state.

Method Details

__construct() public method

public __construct ( array $config, TTools\Provider\StorageProviderInterface $sp = null, TTools\Provider\RequestProviderInterface $rp = null )
$config array
$sp TTools\Provider\StorageProviderInterface
$rp TTools\Provider\RequestProviderInterface

destroy() public method

Destroy a tweet
public destroy ( string $tweet_id ) : array | mixed
$tweet_id string The ID of the tweet
return array | mixed

get() public method

Performs a GET request to the Twitter API
public get ( $path, array $params = [] ) : array
$path
$params array
return array

getCredentials() public method

Get logged user profile
public getCredentials ( ) : array
return array

getCurrentUser() public method

Gets the current logged user, if any.
public getCurrentUser ( ) : User
return User

getFavorites() public method

Gets current user favorites
public getFavorites ( integer $limit = 10 ) : array
$limit integer
return array

getLastReqInfo() public method

Gets information about the last request.
public getLastReqInfo ( ) : array
return array

getLoggedUser() public method

Returns a User object with ArrayAccess. Returns null if there's no logged user.
public getLoggedUser ( ) : User
return User

getLoginUrl() public method

public getLoginUrl ( string $callbackUrl = null ) : string
$callbackUrl string Absolute URL which Twitter redirects to after the user successfully connected with the app
return string

getMentions() public method

Gets mentions for the current user
public getMentions ( integer $limit = 10 ) : array
$limit integer
return array

getProfile() public method

Example: $profile = $ttools->getProfile(array('screen_name' => 'erikaheidi));
public getProfile ( array $params = null ) : array
$params array The twitter user ID or screen_name(optional)
return array

getRemainingCalls() public method

Returns information about the API usage and how many calls you have left.
public getRemainingCalls ( ) : array
return array

getState() public method

Returns current state
public getState ( ) : integer
return integer

getTimeline() public method

Gets the home timeline for current authenticated user
public getTimeline ( integer $limit = 10 ) : array
$limit integer
return array

getTweet() public method

Gets a specific Tweet
public getTweet ( string $tweet_id ) : array
$tweet_id string The tweet id
return array

getUser() public method

Retrieves the Twitter User. If there's no logged user yet, it will check if the user is coming back from the Twitter Auth page and retrieve its tokens.
public getUser ( ) : User
return User Returns a TTools User object or null if there's no logged user.

getUserTimeline() public method

Gets a user timeline (tweets posted by a user). Defaults to the current user timeline
public getUserTimeline ( null $user_id = null, null $screen_name = null, integer $limit = 10 ) : array
$user_id null If specified, will try to get this user id tweets
$screen_name null If specified, will try to get this user screen_name tweets
$limit integer
return array

getUserTokens() public method

public getUserTokens ( ) : array
return array

isLogged() public method

public isLogged ( ) : integer
return integer

linkify() public method

Renders links, hash tags, and account mentions of a Tweet message as clickable links
public linkify ( string $message ) : string
$message string The tweet message
return string

logout() public method

public logout ( ) : mixed
return mixed

post() public method

Performs a POST request to the Twitter API
public post ( $path, $params, boolean $multipart = false ) : array
$path
$params
$multipart boolean
return array

update() public method

Post a tweet
public update ( string $message, string $in_reply_to = null, $media = [] ) : array
$message string The tweet message
$in_reply_to string [optional] A tweet id that this post is replying to. Twitter ignores this param if you don't mention the user in the tweet message.
return array

updateWithMedia() public method

Post a tweet with an image embedded - to keep backwards compatibility
public updateWithMedia ( string $image, string $message, string $in_reply_to = null ) : array
$image string Path to the image file
$message string Message to be posted with the image
$in_reply_to string [optional] A tweet id that this post is replying to. Twitter ignores this param if you don't mention the user in the tweet message.
return array

uploadMedia() public method

Uploads media to uploads.twitter.com to be embedded in tweets
public uploadMedia ( string $image ) : array
$image string Path to the image/media file
return array Response