HTTP_OAuth
[ class tree: HTTP_OAuth ] [ index: HTTP_OAuth ] [ all elements ]

Class: HTTP_OAuth_Consumer

Source Location: /HTTP_OAuth-0.1.6/HTTP/OAuth/Consumer.php

Class Overview

HTTP_OAuth
   |
   --HTTP_OAuth_Consumer

HTTP_OAuth_Consumer


Author(s):

Copyright:

  • 2009 Jeff Hodsdon <jeffhodsdon@gmail.com>

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTTP_OAuth

HTTP_OAuth::attachLog()
Attaches an instance of PEAR Log
HTTP_OAuth::buildHttpQuery()
Build HTTP Query
HTTP_OAuth::debug()
Log debug message
HTTP_OAuth::detachLog()
Detaches an instance of PEAR Log
HTTP_OAuth::err()
Log error message
HTTP_OAuth::info()
Log info message
HTTP_OAuth::log()
Log a message
HTTP_OAuth::urldecode()
URL Decode
HTTP_OAuth::urlencode()
URL Encode

Class Details

[line 66]
HTTP_OAuth_Consumer

Main consumer class that assists consumers in establishing OAuth creditials and making OAuth requests.

  1.  $consumer = new HTTP_OAuth_Consumer('key''secret');
  2.  $consumer->getRequestToken('http://example.com/oauth/request_token, $callback);
  3.  
  4.  // Store tokens
  5.  $_SESSION['token']        = $consumer->getToken();
  6.  $_SESSION['token_secret'] = $consumer->getTokenSecret();
  7.  
  8.  $url = $consumer->getAuthorizationUrl('http://example.com/oauth/authorize');
  9.  http_redirect($url)// function from pecl_http
  10.  
  11.  // When they come back via the $callback url
  12.  $consumer = new HTTP_OAuth_Consumer('key''secret'$_SESSION['token'],
  13.      $_SESSION['token_secret']);
  14.  $consumer->getAccessToken('http://example.com/oauth/access_token');
  15.  
  16.  // Store tokens
  17.  $_SESSION['token']        $consumer->getToken();
  18.  $_SESSION['token_secret'$consumer->getTokenSecret();
  19.  
  20.  // $response is an instance of HTTP_OAuth_Consumer_Response
  21.  $response $consumer->sendRequest('http://example.com/oauth/protected_resource');



[ Top ]


Class Variables

$consumerRequest =  null

[line 111]

Instance of HTTP_OAuth_Consumer_Request



[ Top ]

$key =  null

[line 74]

Consumer key
  • Var: Consumer key
  • Access: protected

Type:   string


[ Top ]

$lastRequest =  null

[line 118]

Instance of the last request made
  • Var: The last request made
  • Access: protected



[ Top ]

$secret =  null

[line 81]

secret
  • Var: Consumer secret
  • Access: protected

Type:   string


[ Top ]

$signatureMethod =  'HMAC-SHA1'

[line 102]

Signature method
  • Var: Signature method
  • Access: protected

Type:   string


[ Top ]

$token =  null

[line 88]

Token
  • Var: Access/Request token
  • Access: protected

Type:   string


[ Top ]

$tokenSecret =  null

[line 95]

Token secret
  • Var: Access/Request token secret
  • Access: protected

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 130]

void __construct( string $key, string $secret, [string $token = null], [string $tokenSecret = null])

Construct
  • Access: public

Parameters:

string   $key     Consumer key
string   $secret     Consumer secret
string   $token     Access/Reqest token
string   $tokenSecret     Access/Reqest token secret

[ Top ]

accept   [line 363]

void accept( HTTP_OAuth_Consumer_Request $object)

Accepts a custom instance of HTTP_OAuth_Consumer_Request.

Parameters:

HTTP_OAuth_Consumer_Request   $object     Custom instance

[ Top ]

getAccessToken   [line 182]

array getAccessToken( string $url, [string $verifier = ''], [ $additional = array()], [string $method = 'POST'])

Get access token
  • Return: Token and token secret
  • Throws: HTTP_OAuth_Consumer_Exception_InvalidResponse Mising token/secret
  • Access: public

Parameters:

string   $url     Access token url
string   $verifier     OAuth verifier from the provider
array   $additional     Additional parameters to be in the request recommended in the spec.
string   $method     HTTP method to use for the request

[ Top ]

getAuthorizeUrl   [line 214]

string getAuthorizeUrl( string $url, [ $additional = array()])

Get authorize url
  • Return: Authorization url
  • Access: public

Parameters:

string   $url     Authorization url
array   $additional     Additional parameters for the auth url

[ Top ]

getKey   [line 262]

string getKey( )

Get key
  • Return: Consumer key
  • Access: public

[ Top ]

getLastRequest   [line 400]

null|HTTP_OAuth_Consumer_Request getLastRequest( )

Gets the last request
  • Return: Instance of the last request
  • See: self::sendRequest()
  • Access: public

[ Top ]

getOAuthConsumerRequest   [line 386]

HTTP_OAuth_Consumer_Request getOAuthConsumerRequest( )

Gets instance of HTTP_OAuth_Consumer_Request

[ Top ]

getRequestToken   [line 150]

void getRequestToken( string $url, [string $callback = 'oob'], [ $additional = array()], [string $method = 'POST'])

Get request token
  • Throws: HTTP_OAuth_Consumer_Exception_InvalidResponse Missing token/secret
  • Access: public

Parameters:

string   $url     Request token url
string   $callback     Callback url
array   $additional     Additional parameters to be in the request recommended in the spec.
string   $method     HTTP method to use for the request

[ Top ]

getSecret   [line 272]

string getSecret( )

Get secret
  • Return: Consumer secret
  • Access: public

[ Top ]

getSecrets   [line 350]

array getSecrets( )

Get secrets
  • Return: Array possible secrets
  • Access: protected

[ Top ]

getSignatureMethod   [line 328]

string getSignatureMethod( )

Get signature method
  • Return: Signature method
  • Access: public

[ Top ]

getToken   [line 282]

string getToken( )

Get token
  • Return: Token
  • Access: public

[ Top ]

getTokenSecret   [line 305]

string getTokenSecret( )

Get token secret
  • Return: Accessoken secret
  • Access: public

[ Top ]

sendRequest   [line 231]

HTTP_OAuth_Consumer_Response sendRequest( string $url, [ $additional = array()], [string $method = 'POST'])

Send request
  • Return: Instance of a response class
  • Access: public

Parameters:

string   $url     URL of the protected resource
array   $additional     Additional parameters
string   $method     HTTP method to use

[ Top ]

setSignatureMethod   [line 340]

void setSignatureMethod( string $method)

Set signature method
  • Access: public

Parameters:

string   $method     Signature method to use

[ Top ]

setToken   [line 294]

void setToken( string $token)

Set token
  • Access: public

Parameters:

string   $token     Request/Access token

[ Top ]

setTokenSecret   [line 317]

void setTokenSecret( string $secret)

Set token secret
  • Access: public

Parameters:

string   $secret     Token secret

[ Top ]


Documentation generated on Mon, 30 Nov 2009 23:00:04 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.