PHP Class TTools\TTools

Show file Open project: ttools/ttools Class Usage Examples

Public Methods

Method Description
__construct ( array $config )
getAccessTokens ( string $request_token, string $request_secret, string $oauth_verifier ) : array Makes a Request to get the user access tokens
getAuthorizeUrl ( array $params = [] ) : array Gets the authorization url.
getLastReqInfo ( ) : array
getUserTokens ( ) : array Gets the current user tokens
handleError ( OAuthResponse $response ) : array
makeRequest ( $url, array $params = [], string $method = 'GET', boolean $multipart = false ) : array | mixed
setUserTokens ( string $at, string $ats ) Sets the current user tokens
uploadMedia ( string $image ) : array | mixed

Private Methods

Method Description
OAuthRequest ( $url, array $params = [], string $method = 'GET', null $callback = null, boolean $multipart = false ) : array | OAuthResponse
parseResponse ( $string ) : array

Method Details

__construct() public method

public __construct ( array $config )
$config array

getAccessTokens() public method

Makes a Request to get the user access tokens
public getAccessTokens ( string $request_token, string $request_secret, string $oauth_verifier ) : array
$request_token string
$request_secret string
$oauth_verifier string
return array Returns an array with the user data and tokens, or an error array with code and message

getAuthorizeUrl() public method

Gets the authorization url.
public getAuthorizeUrl ( array $params = [] ) : array
$params array Custom parameters passed to the OAuth request
return array If successful, returns an array with 'auth_url', 'secret' and 'token'; otherwise, returns an array with error code and message.

getLastReqInfo() public method

public getLastReqInfo ( ) : array
return array

getUserTokens() public method

Gets the current user tokens
public getUserTokens ( ) : array
return array Returns an array where the first position is the Access Token and the second position is the Access Token Secret

handleError() public method

public handleError ( OAuthResponse $response ) : array
$response OAuthResponse
return array

makeRequest() public method

public makeRequest ( $url, array $params = [], string $method = 'GET', boolean $multipart = false ) : array | mixed
$url
$params array
$method string
$multipart boolean
return array | mixed

setUserTokens() public method

Sets the current user tokens
public setUserTokens ( string $at, string $ats )
$at string Access Token
$ats string Access Token Secret

uploadMedia() public method

public uploadMedia ( string $image ) : array | mixed
$image string Path to the image
return array | mixed