Web Services
Introduction
Web Services
PHP Manual

# OAuth

Table of Contents

- Introduction
- Installing/Configuring
  - Requirements
  - Installation
  - Runtime Configuration
  - Resource Types
- Predefined Constants
- Examples
  - FireEagle
- OAuth Functions
  - oauth_get_sbs — Generate a Signature Base String
  - oauth_urlencode — Encode a URI to RFC 3986
- OAuth — The OAuth class
  - OAuth::__construct — Create a new OAuth object
  - OAuth::__destruct — The destructor
  - OAuth::disableDebug — Turn off verbose debugging
  - OAuth::disableRedirects — Turn off redirects
  - OAuth::disableSSLChecks — Turn off SSL checks
  - OAuth::enableDebug — Turn on verbose debugging
  - OAuth::enableRedirects — Turn on redirects
  - OAuth::enableSSLChecks — Turn on SSL checks
  - OAuth::fetch — Fetch an OAuth protected resource
  - OAuth::generateSignature — Generate a signature
  - OAuth::getAccessToken — Fetch an access token
  - OAuth::getCAPath — Gets CA information
  - OAuth::getLastResponse — Get the last response
  - OAuth::getLastResponseHeaders — Get headers for last response
  - OAuth::getLastResponseInfo — Get HTTP information about the last response
  - OAuth::getRequestHeader — Generate OAuth header string signature
  - OAuth::getRequestToken — Fetch a request token
  - OAuth::setAuthType — Set authorization type
  - OAuth::setCAPath — Set CA path and info
  - OAuth::setNonce — Set the nonce for subsequent requests
  - OAuth::setRequestEngine — The setRequestEngine purpose
  - OAuth::setRSACertificate — Set the RSA certificate
  - OAuth::setSSLChecks — Tweak specific SSL checks for requests.
  - OAuth::setTimestamp — Set the timestamp
  - OAuth::setToken — Sets the token and secret
  - OAuth::setVersion — Set the OAuth version
- OAuthProvider — The OAuthProvider class
  - OAuthProvider::addRequiredParameter — Add required parameters
  - OAuthProvider::callconsumerHandler — Calls the consumerNonceHandler callback
  - OAuthProvider::callTimestampNonceHandler — Calls the timestampNonceHandler callback
  - OAuthProvider::calltokenHandler — Calls the tokenNonceHandler callback
  - OAuthProvider::checkOAuthRequest — Check an oauth request
  - OAuthProvider::__construct — Constructs a new OAuthProvider object
  - OAuthProvider::consumerHandler — Set the consumerHandler handler callback
  - OAuthProvider::generateToken — Generate a random token
  - OAuthProvider::is2LeggedEndpoint — is2LeggedEndpoint
  - OAuthProvider::isRequestTokenEndpoint — Sets isRequestTokenEndpoint
  - OAuthProvider::removeRequiredParameter — Remove a required parameter
  - OAuthProvider::reportProblem — Report a problem
  - OAuthProvider::setParam — Set a parameter
  - OAuthProvider::setRequestTokenPath — Set request token path
  - OAuthProvider::timestampNonceHandler — Set the timestampNonceHandler handler callback
  - OAuthProvider::tokenHandler — Set the tokenHandler handler callback
- OAuthException — OAuthException class

# The OAuth class

## Introduction

The OAuth extension provides a simple interface to interact with data providers using the OAuth HTTP specification to protect private resources.

## Class synopsis

OAuth
class OAuth {
/* Properties */
public $debug ;
public $sslChecks ;
public $debugInfo ;
/* Methods */
public __construct ( string `$consumer_key` , string `$consumer_secret` [, string `$signature_method` = `OAUTH_SIG_METHOD_HMACSHA1` [, int `$auth_type` = 0 ]] )
public void __destruct ( void )
public bool disableDebug ( void )
public bool disableRedirects ( void )
public bool disableSSLChecks ( void )
public bool enableDebug ( void )
public bool enableRedirects ( void )
public bool enableSSLChecks ( void )
public mixed fetch ( string `$protected_resource_url` [, array `$extra_parameters` [, string `$http_method` [, array `$http_headers` ]]] )
public string generateSignature ( string `$http_method` , string `$url` [, mixed `$extra_parameters` ] )
public array getAccessToken ( string `$access_token_url` [, string `$auth_session_handle` [, string `$verifier_token` ]] )
public array getCAPath ( void )
public string getLastResponse ( void )
public string getLastResponseHeaders ( void )
public array getLastResponseInfo ( void )
public string getRequestHeader ( string `$http_method` , string `$url` [, mixed `$extra_parameters` ] )
public array getRequestToken ( string `$request_token_url` [, string `$callback_url` ] )
public mixed setAuthType ( int `$auth_type` )
public mixed setCAPath ([ string `$ca_path` [, string `$ca_info` ]] )
public mixed setNonce ( string `$nonce` )
public void setRequestEngine ( int `$reqengine` )
public mixed setRSACertificate ( string `$cert` )
public bool setSSLChecks ( int `$sslcheck` )
public mixed setTimestamp ( string `$timestamp` )
public bool setToken ( string `$token` , string `$token_secret` )
public bool setVersion ( string `$version` )
}

## Properties

debug

sslChecks

debugInfo

# The OAuthProvider class

## Introduction

Manages an OAuth provider class.

See also an external in-depth tutorial titled » Writing an OAuth Provider Service, which takes a hands-on approach to providing this service. There are also » OAuth provider examples within the OAuth extensions sources.

## Class synopsis

OAuthProvider
class OAuthProvider {
/* Methods */
final public bool addRequiredParameter ( string `$req_params` )
public void callconsumerHandler ( void )
public void callTimestampNonceHandler ( void )
public void calltokenHandler ( void )
public void checkOAuthRequest ([ string `$uri` [, string `$method` ]] )
public __construct ([ array `$params_array` ] )
public void consumerHandler ( callable `$callback_function` )
final public static string generateToken ( int `$size` [, bool `$strong` = false ] )
public void is2LeggedEndpoint ( mixed `$params_array` )
public void isRequestTokenEndpoint ( bool `$will_issue_request_token` )
final public bool removeRequiredParameter ( string `$req_params` )
final public static string reportProblem ( string `$oauthexception` [, bool `$send_headers` = true ] )
final public bool setParam ( string `$param_key` [, mixed `$param_val` ] )
final public bool setRequestTokenPath ( string `$path` )
public void timestampNonceHandler ( callable `$callback_function` )
public void tokenHandler ( callable `$callback_function` )
}

# OAuthException class

## Introduction

This exception is thrown when exceptional errors occur while using the OAuth extension and contains useful debugging information.

## Class synopsis

OAuthException
class OAuthException extends Exception {
/* Properties */
public $lastResponse ;
public $debugInfo ;
/* Inherited properties */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Inherited methods */
final public string Exception::getMessage ( void )
final public Exception Exception::getPrevious ( void )
final public mixed Exception::getCode ( void )
final public string Exception::getFile ( void )
final public int Exception::getLine ( void )
final public array Exception::getTrace ( void )
final public string Exception::getTraceAsString ( void )
public string Exception::__toString ( void )
final private void Exception::__clone ( void )
}

## Properties

lastResponse

  The response of the exception which occurred, if any

debugInfo