Documentation

HttpClient

REST API HTTP Client class.

Table of Contents

$ch  : resource
cURL handle.
$consumerKey  : string
Consumer key.
$consumerSecret  : string
Consumer secret.
$options  : Options
Client options.
$url  : string
Store API URL.
$request  : Request
Request.
$response  : Response
Response.
$responseHeaders  : string
Response headers.
__construct()  : mixed
Initialize HTTP client.
getRequest()  : Request
Get request data.
getResponse()  : Response
Get response data.
request()  : array<string|int, mixed>
Make requests.
authenticate()  : array<string|int, mixed>
Authenticate.
buildApiUrl()  : string
Build API URL.
buildUrlQuery()  : string
Build URL.
createRequest()  : Request
Create request.
createResponse()  : Response
Create response.
getRequestHeaders()  : array<string|int, mixed>
Get request headers.
getResponseHeaders()  : array<string|int, mixed>
Get response headers.
isSsl()  : bool
Check if is under SSL.
lookForErrors()  : mixed
Look for errors in the request.
processResponse()  : array<string|int, mixed>
Process response.
setDefaultCurlSettings()  : mixed
Set default cURL settings.
setupMethod()  : mixed
Setup method.

Properties

$consumerKey

Consumer key.

protected string $consumerKey

$consumerSecret

Consumer secret.

protected string $consumerSecret

$responseHeaders

Response headers.

private string $responseHeaders

Methods

__construct()

Initialize HTTP client.

public __construct(string $url, string $consumerKey, string $consumerSecret, array<string|int, mixed> $options) : mixed
Parameters
$url : string

Store URL.

$consumerKey : string

Consumer key.

$consumerSecret : string

Consumer Secret.

$options : array<string|int, mixed>

Client options.

Return values
mixed

request()

Make requests.

public request(string $endpoint, string $method[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $parameters = [] ]) : array<string|int, mixed>
Parameters
$endpoint : string

Request endpoint.

$method : string

Request method.

$data : array<string|int, mixed> = []

Request data.

$parameters : array<string|int, mixed> = []

Request parameters.

Return values
array<string|int, mixed>

authenticate()

Authenticate.

protected authenticate(string $url, string $method[, array<string|int, mixed> $parameters = [] ]) : array<string|int, mixed>
Parameters
$url : string

Request URL.

$method : string

Request method.

$parameters : array<string|int, mixed> = []

Request parameters.

Return values
array<string|int, mixed>

buildApiUrl()

Build API URL.

protected buildApiUrl(string $url) : string
Parameters
$url : string

Store URL.

Return values
string

buildUrlQuery()

Build URL.

protected buildUrlQuery(string $url[, array<string|int, mixed> $parameters = [] ]) : string
Parameters
$url : string

URL.

$parameters : array<string|int, mixed> = []

Query string parameters.

Return values
string

createRequest()

Create request.

protected createRequest(string $endpoint, string $method[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $parameters = [] ]) : Request
Parameters
$endpoint : string

Request endpoint.

$method : string

Request method.

$data : array<string|int, mixed> = []

Request data.

$parameters : array<string|int, mixed> = []

Request parameters.

Return values
Request

getRequestHeaders()

Get request headers.

protected getRequestHeaders([bool $sendData = false ]) : array<string|int, mixed>
Parameters
$sendData : bool = false

If request send data or not.

Return values
array<string|int, mixed>

getResponseHeaders()

Get response headers.

protected getResponseHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

isSsl()

Check if is under SSL.

protected isSsl() : bool
Return values
bool

lookForErrors()

Look for errors in the request.

protected lookForErrors(array<string|int, mixed> $parsedResponse) : mixed
Parameters
$parsedResponse : array<string|int, mixed>

Parsed body response.

Return values
mixed

processResponse()

Process response.

protected processResponse() : array<string|int, mixed>
Return values
array<string|int, mixed>

setDefaultCurlSettings()

Set default cURL settings.

protected setDefaultCurlSettings() : mixed
Return values
mixed

setupMethod()

Setup method.

protected setupMethod(string $method) : mixed
Parameters
$method : string

Request method.

Return values
mixed

Search results