Public Member Functions | |
addHeader (string $name, string $value) | |
getHeaders () | |
addParameter (string $name, $value=null) | |
getParameter (string $name) | |
getParameters () | |
getApiUri () | |
getEndpointPath () | |
getVerb () | |
getRequiresAuthentication () | |
getMandatoryParameters () | |
validate () | |
Public Member Functions inherited from snuze\SnuzeObject | |
__construct (array $args=null) | |
_getSnuzeId () | |
_getSnuzeClass () | |
_ident () | |
Static Public Member Functions | |
static | getValidParameters () |
static | getValidVerbs () |
Public Attributes | |
const | API_URIS |
const | VERB_GET = 'GET' |
const | VERB_POST = 'POST' |
const | VERB_DELETE = 'DELETE' |
Protected Member Functions | |
setApiUri (string $apiUri) | |
setEndpointPath (string $endpointPath) | |
setVerb (string $verb) | |
setRequiresAuthentication (bool $requiresAuthentication) | |
Protected Member Functions inherited from snuze\SnuzeObject | |
debug (string $message, bool $echo=false) | |
info (string $message, bool $echo=false) | |
warning (string $message, bool $echo=false) | |
error (string $message, bool $echo=false) | |
Protected Attributes | |
$parameters = [] | |
$mandatoryParameters = [] | |
Protected Attributes inherited from snuze\SnuzeObject | |
$_snuzeId = null | |
$_snuzeClass = null | |
Private Attributes | |
$apiUri = self::API_URIS['authenticated'] | |
$endpointPath = null | |
$verb = self::VERB_GET | |
$requiresAuthentication = true | |
$headers = [] | |
Request represents the common features of any request that will be sent to the Reddit API. The target URI, HTTP verb, and any headers or parameters (query string or POST fields) are all stored in this object.
You can't instantiate a generic Request; instead, you should create and use the various subtypes.
This file is part of Snuze, a PHP client for the Reddit API. Copyright 2019 Shaun Cummiskey shaun @sha unc.c omhttps://shaunc.com/ Repository: https://github.com/snuze/snuze/ Documentation: https://snuze.shaunc.com/
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
snuze\Request\Request::addHeader | ( | string | $name, |
string | $value | ||
) |
Add an HTTP header to this request.
string | $name | The name of the header, e.g. 'Connection' |
string | $value | The value of the header, e.g. 'Close' |
snuze\Request\Request::addParameter | ( | string | $name, |
$value = null |
|||
) |
Add a parameter to the query string or POST data for this Request.
If the parameter already exists, it will be overwritten with the new value. If $value is empty, the parameter will be unset.
string | $name | The name of the parameter, e.g. 'link_fullname' |
scalar | null | $value | The value of the parameter, e.g. 't3_chungus' |
References snuze\Request\Request\getValidParameters().
snuze\Request\Request::getApiUri | ( | ) |
Get the API base URI for this type of Request
snuze\Request\Request::getEndpointPath | ( | ) |
Get the API endpoint path for this type of Request
snuze\Request\Request::getHeaders | ( | ) |
Get the array of HTTP headers configured for this Request.
snuze\Request\Request::getMandatoryParameters | ( | ) |
snuze\Request\Request::getParameter | ( | string | $name | ) |
Get the value of a single parameter, by name; or null if it's not set
string | $name | The name of the parameter to retrieve |
snuze\Request\Request::getParameters | ( | ) |
Get the array of parameters configured for this Request.
snuze\Request\Request::getRequiresAuthentication | ( | ) |
|
static |
|
static |
Get an array of supported HTTP verbs.
snuze\Request\Request::getVerb | ( | ) |
Get the HTTP verb configured for this Request type
|
protected |
|
protected |
Set the API endpoint path to which this request will be posted.
string | $endpointPath | The API endpoint path e.g. "/api/foo/bar" |
|
protected |
|
protected |
Set the HTTP verb that will be used for this Request type
string | $verb | One of the self::VERB_ constants |
References snuze\Request\Request\getValidVerbs().
snuze\Request\Request::validate | ( | ) |
const snuze\Request\Request::API_URIS |
The base URIs to which API requests are sent. Requests to obtain an authorization token must be made to the "unauthenticated" URI. Most other requests are generally made to the "authenticated" URI.
Don't edit these values unless you have a phenomenally good reason.
const snuze\Request\Request::VERB_DELETE = 'DELETE' |
Define the HTTP DELETE verb as valid
const snuze\Request\Request::VERB_GET = 'GET' |
Define the HTTP GET verb as valid
const snuze\Request\Request::VERB_POST = 'POST' |
Define the HTTP POST verb as valid