PHP Class OAuthClient

Show file Open project: baserproject/basercms Class Usage Examples

Public Methods

Method Description
__construct ( $consumerKey, $consumerSecret = '' )
get ( $accessTokenKey, $accessTokenSecret, $url, array $getData = [] ) Call API with a GET request. Returns either false on failure or an HttpResponse object.
getAccessToken ( $accessTokenURL, $requestToken, $httpMethod = 'POST', array $parameters = [] )
getFullResponse ( ) Returns an HttpResponse object for the previous request, or null, if there was no request.
getRequestToken ( $requestTokenURL, $callback = 'oob', $httpMethod = 'POST', array $parameters = [] )
post ( $accessTokenKey, $accessTokenSecret, $url, array $postData = [] ) Call API with a POST request. Returns either false on failure or an HttpResponse object.
postMultipartFormData ( $accessTokenKey, $accessTokenSecret, $url, array $paths, array $postData = [] ) Call API with a POST request, the content type set to multipart/form-data.

Protected Methods

Method Description
createOAuthToken ( array $response )

Private Methods

Method Description
createConsumer ( )
createRequest ( $httpMethod, $url, $token, array $parameters )
doGet ( $url )
doPost ( $url, $data )
doPostMultipartFormData ( $url, $authorization, $paths, $data )
getToken ( $request )

Method Details

__construct() public method

public __construct ( $consumerKey, $consumerSecret = '' )

createOAuthToken() protected method

protected createOAuthToken ( array $response )
$response array

get() public method

Call API with a GET request. Returns either false on failure or an HttpResponse object.
public get ( $accessTokenKey, $accessTokenSecret, $url, array $getData = [] )
$getData array

getAccessToken() public method

public getAccessToken ( $accessTokenURL, $requestToken, $httpMethod = 'POST', array $parameters = [] )
$parameters array

getFullResponse() public method

Returns an HttpResponse object for the previous request, or null, if there was no request.
public getFullResponse ( )

getRequestToken() public method

public getRequestToken ( $requestTokenURL, $callback = 'oob', $httpMethod = 'POST', array $parameters = [] )
$requestTokenURL
$callback An absolute URL to which the server will redirect the resource owner back when the Resource Owner Authorization step is completed. If the client is unable to receive callbacks or a callback URL has been established via other means, the parameter value MUST be set to oob (case sensitive), to indicate an out-of-band configuration. Section 2.1 from http://tools.ietf.org/html/rfc5849
$httpMethod 'POST' or 'GET'
$parameters array

post() public method

Call API with a POST request. Returns either false on failure or an HttpResponse object.
public post ( $accessTokenKey, $accessTokenSecret, $url, array $postData = [] )
$postData array

postMultipartFormData() public method

This is, for example, necessary for Twitter's update_with_media API method (https://dev.twitter.com/docs/api/1/post/statuses/update_with_media) $paths a key-value array, example: array('media[]' => '/home/dho/avatar.png') Returns either false on failure or an HttpResponse object.
public postMultipartFormData ( $accessTokenKey, $accessTokenSecret, $url, array $paths, array $postData = [] )
$paths array
$postData array