LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
OAuthRequest Class Reference

Class to represent an OAuth request. More...

Public Member Functions

 __construct ($http_method, $http_url, $parameters=null)
 Class constructor.
 
 set_parameter ($name, $value, $allow_duplicates=true)
 Set a parameter.
 
 get_parameter ($name)
 Get a parameter.
 
 get_parameters ()
 Get request parameters.
 
 unset_parameter ($name)
 Delete a parameter.
 
 get_signable_parameters ()
 The request parameters, sorted and concatenated into a normalized string.
 
 get_signature_base_string ()
 Returns the base string of this request.
 
 get_normalized_http_method ()
 Just uppercases the http method.
 
 get_normalized_http_url ()
 Parses the url and rebuilds it to be scheme://host/path.
 
 to_url ()
 Builds a url usable for a GET request.
 
 to_postdata ()
 Builds the data one would send in a POST request.
 
 to_header ($realm=null)
 Builds the Authorization: header.
 
 __toString ()
 Convert object to a string.
 
 sign_request ($signature_method, $consumer, $token)
 Sign the request.
 
 build_signature ($signature_method, $consumer, $token)
 Build the signature.
 

Static Public Member Functions

static from_request ($http_method=null, $http_url=null, $parameters=null)
 Attempt to build up a request from what was passed to the server.
 
static from_consumer_and_token ($consumer, $token, $http_method, $http_url, $parameters=null)
 Pretty much a helper function to set up the request.
 

Data Fields

 $base_string
 Base string.
 

Static Public Attributes

static $version = '1.0'
 Version.
 
static $POST_INPUT = 'php://input'
 Access to POST data.
 

Protected Attributes

 $parameters
 Request parameters.
 
 $http_method
 HTTP method.
 
 $http_url
 HTTP URL.
 

Detailed Description

Class to represent an OAuth request.

Version
2008-08-04
Licence: https://opensource.org/licenses/MIT The MIT License

Definition at line 12 of file OAuthRequest.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $http_method,
  $http_url,
  $parameters = null 
)

Class constructor.

Parameters
string$http_methodHTTP method
string$http_urlHTTP URL
array | null$parametersRequest parameters

Definition at line 66 of file OAuthRequest.php.

References OAuthRequest\$http_method, OAuthRequest\$http_url, OAuthRequest\$parameters, and OAuthUtil\parse_parameters().

Member Function Documentation

◆ __toString()

__toString ( )

Convert object to a string.

Returns
string

Definition at line 373 of file OAuthRequest.php.

References OAuthRequest\to_url().

◆ build_signature()

build_signature (   $signature_method,
  $consumer,
  $token 
)

Build the signature.

Parameters
OAuthSignatureMethod$signature_methodSignature method
OAuthConsumer$consumerConsumer
OAuthToken | null$tokenToken
Returns
string

Definition at line 403 of file OAuthRequest.php.

Referenced by OAuthRequest\sign_request().

◆ from_consumer_and_token()

static from_consumer_and_token (   $consumer,
  $token,
  $http_method,
  $http_url,
  $parameters = null 
)
static

Pretty much a helper function to set up the request.

Parameters
OAuthConsumer$consumerConsumer
OAuthToken | null$tokenToken
string$http_methodHTTP method
string$http_urlHTTP URL
array | null$parametersRequest parameters
Returns
OAuthRequest

Definition at line 165 of file OAuthRequest.php.

References OAuthRequest\$http_method, OAuthRequest\$http_url, OAuthRequest\$parameters, and OAuthRequest\$version.

◆ from_request()

static from_request (   $http_method = null,
  $http_url = null,
  $parameters = null 
)
static

Attempt to build up a request from what was passed to the server.

Parameters
string | null$http_methodHTTP method
string | null$http_urlHTTP URL
array | null$parametersRequest parameters
Returns
OAuthRequest

Definition at line 84 of file OAuthRequest.php.

References OAuthRequest\$http_method, OAuthRequest\$http_url, OAuthRequest\$parameters, OAuthUtil\get_headers(), OAuthUtil\parse_parameters(), and OAuthUtil\split_header().

◆ get_normalized_http_method()

get_normalized_http_method ( )

Just uppercases the http method.

Returns
string

Definition at line 281 of file OAuthRequest.php.

Referenced by OAuthRequest\get_signature_base_string().

◆ get_normalized_http_url()

get_normalized_http_url ( )

Parses the url and rebuilds it to be scheme://host/path.

Returns
string

Definition at line 291 of file OAuthRequest.php.

Referenced by OAuthRequest\get_signature_base_string(), and OAuthRequest\to_url().

◆ get_parameter()

get_parameter (   $name)

Get a parameter.

Parameters
string$nameParameter name
Returns
string|null

Definition at line 210 of file OAuthRequest.php.

◆ get_parameters()

get_parameters ( )

Get request parameters.

Returns
array

Definition at line 220 of file OAuthRequest.php.

References OAuthRequest\$parameters.

◆ get_signable_parameters()

get_signable_parameters ( )

The request parameters, sorted and concatenated into a normalized string.

Returns
string

Definition at line 240 of file OAuthRequest.php.

References OAuthRequest\$parameters, and OAuthUtil\build_http_query().

Referenced by OAuthRequest\get_signature_base_string().

◆ get_signature_base_string()

get_signature_base_string ( )

Returns the base string of this request.

The base string defined as the method, the url and the parameters (normalized), each urlencoded and then concatenated with &.

Returns
string

Definition at line 263 of file OAuthRequest.php.

References OAuthRequest\get_normalized_http_method(), OAuthRequest\get_normalized_http_url(), OAuthRequest\get_signable_parameters(), and OAuthUtil\urlencode_rfc3986().

◆ set_parameter()

set_parameter (   $name,
  $value,
  $allow_duplicates = true 
)

Set a parameter.

Parameters
string$nameParameter name
string$valueParameter value
bool$allow_duplicatesTrue if duplicates are allowed

Definition at line 187 of file OAuthRequest.php.

Referenced by OAuthRequest\sign_request().

◆ sign_request()

sign_request (   $signature_method,
  $consumer,
  $token 
)

Sign the request.

Parameters
OAuthSignatureMethod$signature_methodSignature method
OAuthConsumer$consumerConsumer
OAuthToken | null$tokenToken

Definition at line 385 of file OAuthRequest.php.

References OAuthRequest\build_signature(), and OAuthRequest\set_parameter().

◆ to_header()

to_header (   $realm = null)

Builds the Authorization: header.

Parameters
string | null$realmRealm
Returns
string
Exceptions
OAuthException

Definition at line 341 of file OAuthRequest.php.

References OAuthUtil\urlencode_rfc3986().

◆ to_postdata()

to_postdata ( )

Builds the data one would send in a POST request.

Returns
string

Definition at line 328 of file OAuthRequest.php.

References OAuthUtil\build_http_query().

Referenced by OAuthRequest\to_url().

◆ to_url()

to_url ( )

Builds a url usable for a GET request.

Returns
string

Definition at line 312 of file OAuthRequest.php.

References OAuthRequest\get_normalized_http_url(), and OAuthRequest\to_postdata().

Referenced by OAuthRequest\__toString().

◆ unset_parameter()

unset_parameter (   $name)

Delete a parameter.

Parameters
string$nameParameter name

Definition at line 230 of file OAuthRequest.php.

Field Documentation

◆ $base_string

string $base_string

Base string.

Definition at line 43 of file OAuthRequest.php.

◆ $http_method

string $http_method
protected

◆ $http_url

string $http_url
protected

◆ $parameters

◆ $POST_INPUT

string $POST_INPUT = 'php://input'
static

Access to POST data.

Definition at line 57 of file OAuthRequest.php.

Referenced by System\getRawParameters(), and Util\logRequest().

◆ $version

string $version = '1.0'
static

Version.

Definition at line 50 of file OAuthRequest.php.

Referenced by OAuthRequest\from_consumer_and_token().


The documentation for this class was generated from the following file: