Constants

REQUEST_METHOD_HEADER

REQUEST_METHOD_HEADER = 'header'

Consumer request method constants. See http://oauth.net/core/1.0/#consumer_req_param

REQUEST_METHOD_QUERY

REQUEST_METHOD_QUERY = 'query'

Properties

Methods

__construct()

__construct(array  $config) 

Create a new OAuth 1.0 plugin

Parameters

array $config

Configuration array containing these parameters:

  • string 'request_method' Consumer request method. Use the class constants.
  • string 'callback' OAuth callback
  • string 'consumer_key' Consumer key
  • string 'consumer_secret' Consumer secret
  • string 'token' Token
  • string 'token_secret' Token secret
  • string 'verifier' OAuth verifier.
  • string 'version' OAuth version. Defaults to 1.0
  • string 'signature_method' Custom signature method
  • bool 'disable_post_params' Set to true to prevent POST parameters from being signed
  • array|Closure 'signature_callback' Custom signature callback that accepts a string to sign and a signing key

getSubscribedEvents()

getSubscribedEvents() : array

Returns an array of event names this subscriber wants to listen to.

The array keys are event names and the value can be:

  • The method name to call (priority defaults to 0)
  • An array composed of the method name to call and the priority
  • An array of arrays composed of the method names to call and respective priorities, or 0 if unset

For instance:

  • array('eventName' => 'methodName')
  • array('eventName' => array('methodName', $priority))
  • array('eventName' => array(array('methodName1', $priority), array('methodName2')))

Returns

array —

The event names to listen to

onRequestBeforeSend()

onRequestBeforeSend(\Guzzle\Common\Event  $event) : array

Request before-send event handler

Parameters

\Guzzle\Common\Event $event

Event received

Throws

\InvalidArgumentException

Returns

array

getSignature()

getSignature(\Guzzle\Http\Message\RequestInterface  $request, integer  $timestamp, string  $nonce) : string

Calculate signature for request

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request to generate a signature for

integer $timestamp

Timestamp to use for nonce

string $nonce

Returns

string

getStringToSign()

getStringToSign(\Guzzle\Http\Message\RequestInterface  $request, integer  $timestamp, string  $nonce) : string

Calculate string to sign

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request to generate a signature for

integer $timestamp

Timestamp to use for nonce

string $nonce

Returns

string

getParamsToSign()

getParamsToSign(\Guzzle\Http\Message\RequestInterface  $request, integer  $timestamp, string  $nonce) : array

Get all of the parameters required to sign a request including: * The oauth params * The request GET params * The params passed in the POST body (with a content-type of application/x-www-form-urlencoded)

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request to generate a signature for

integer $timestamp

Timestamp to use for nonce

string $nonce

Returns

array

shouldPostFieldsBeSigned()

shouldPostFieldsBeSigned(  $request) : boolean

Decide whether the post fields should be added to the base string that Oauth signs.

This implementation is correct. Non-conformant APIs may require that this method be overwritten e.g. the Flickr API incorrectly adds the post fields when the Content-Type is 'application/x-www-form-urlencoded'

Parameters

$request

Returns

boolean —

Whether the post fields should be signed or not

generateNonce()

generateNonce(\Guzzle\Http\Message\RequestInterface  $request) : string

Returns a Nonce Based on the unique id and URL. This will allow for multiple requests in parallel with the same exact timestamp to use separate nonce's.

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request to generate a nonce for

Returns

string

getTimestamp()

getTimestamp(\Guzzle\Common\Event  $event) : integer

Gets timestamp from event or create new timestamp

Parameters

\Guzzle\Common\Event $event

Event containing contextual information

Returns

integer

getOauthParams()

getOauthParams(  $timestamp,   $nonce) : \Guzzle\Common\Collection

Get the oauth parameters as named by the oauth spec

Parameters

$timestamp
$nonce

Returns

\Guzzle\Common\Collection

prepareParameters()

prepareParameters(array  $data) : array

Convert booleans to strings, removed unset parameters, and sorts the array

Parameters

array $data

Data array

Returns

array

buildAuthorizationHeader()

buildAuthorizationHeader(array  $authorizationParams) : string

Builds the Authorization header for a request

Parameters

array $authorizationParams

Associative array of authorization parameters

Returns

string