PHP Class OAuthClient

Afficher le fichier Open project: baserproject/basercms Class Usage Examples

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode Description
createOAuthToken ( array $response )

Private Methods

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

Method Details

__construct() public méthode

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

createOAuthToken() protected méthode

protected createOAuthToken ( array $response )
$response array

get() public méthode

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 méthode

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

getFullResponse() public méthode

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

getRequestToken() public méthode

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 méthode

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 méthode

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