\KorbaAPI

Class API helps access API quickly.

A class to help quickly make request to api endpoints. Only Content-Type application/json is supported. And methods currently supported are GET and POST.

Summary

Methods
Properties
Constants
__construct()
No public properties found
No constants found
call()
No protected properties found
N/A
engine()
$base_url
$headers
$proxy_url
$proxy_auth
N/A

Properties

$base_url

$base_url : string

Type

string — The base url of the api request endpoint.

$headers

$headers : array

Type

array — The headers that will be appended to each request.

$proxy_url

$proxy_url : string|null

Type

string|null — The proxy url to be used request.

$proxy_auth

$proxy_auth : string|null

Type

string|null — The proxy authentication in the form basic auth.

Methods

__construct()

__construct(string  $base_url, array  $headers, null|string  $proxy = null) 

API constructor.

It used to create a new instance of the API Class.

Parameters

string $base_url

Base url of the api endpoint.

array $headers

Headers to include in each api request.

null|string $proxy

Proxy url to parse into the various components.

call()

call(string  $endpoint, string|array  $data, array  $extra_headers = null) : boolean|string

API protected function call.

A function used to make request to api endpoint. It clean the input data to a form suitable usable by the class

Parameters

string $endpoint

Endpoint to be used in addition to the base_url to construct full url path.

string|array $data

JsonEncoded string of the intended request data to send as the request body.

array $extra_headers

The result return after try to or connecting to the api endpoint.

Returns

boolean|string

engine()

engine(string  $end_point, string  $data = null, array  $extra_headers = null) : boolean|string

API private function engine.

A function used by the API class to actually make a curl request to the intended api endpoint.

Parameters

string $end_point

Endpoint to be used in addition to the base_url to construct full url path.

string $data

JsonEncoded string of the intended request data to send as the request body.

array $extra_headers

Any Extra headers that needs to be added to specific request.

Returns

boolean|string —

The result return after try to or connecting to the api endpoint.