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

Static Public Member Functions

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

Public Attributes

string $base_string
 Base string.
 

Static Public Attributes

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

Protected Attributes

array $parameters
 Request parameters.
 
string $http_method
 HTTP method.
 
string $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

Constructor & Destructor Documentation

◆ __construct()

__construct ( string $http_method,
string $http_url,
?array $parameters = null )

Class constructor.

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

Member Function Documentation

◆ __toString()

string __toString ( )

Convert object to a string.

Returns
string

◆ build_signature()

string build_signature ( OAuthSignatureMethod $signature_method,
OAuthConsumer $consumer,
?OAuthToken $token )

Build the signature.

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

◆ from_consumer_and_token()

static OAuthRequest from_consumer_and_token ( OAuthConsumer $consumer,
?OAuthToken $token,
string $http_method,
string $http_url,
?array $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

◆ from_request()

static OAuthRequest from_request ( ?string $http_method = null,
?string $http_url = null,
?array $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

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

◆ get_normalized_http_method()

string get_normalized_http_method ( )

Just uppercases the http method.

Returns
string

References OAuthUtil\build_http_query().

◆ get_normalized_http_url()

string get_normalized_http_url ( )

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

Returns
string

References OAuthUtil\urlencode_rfc3986().

◆ get_parameter()

string array null get_parameter ( string $name)

Get a parameter.

Parameters
string$nameParameter name
Returns
string|array|null

◆ get_parameters()

array get_parameters ( )

Get request parameters.

Returns
array

◆ get_signable_parameters()

string get_signable_parameters ( )

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

Returns
string

◆ get_signature_base_string()

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

◆ set_parameter()

void set_parameter ( string $name,
string $value,
bool $allow_duplicates = true )

Set a parameter.

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

◆ sign_request()

void sign_request ( OAuthSignatureMethod $signature_method,
OAuthConsumer $consumer,
?OAuthToken $token )

Sign the request.

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

◆ to_header()

string to_header ( ?string $realm = null)

Builds the Authorization: header.

Parameters
string | null$realmRealm
Returns
string
Exceptions
OAuthException

◆ to_postdata()

string to_postdata ( )

Builds the data one would send in a POST request.

Returns
string

◆ to_url()

string to_url ( )

Builds a url usable for a GET request.

Returns
string

◆ unset_parameter()

void unset_parameter ( string $name)

Delete a parameter.

Parameters
string$nameParameter name