$base_url
$base_url : string
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.
__construct(string $base_url, array $headers, null|string $proxy = null)
API constructor.
It used to create a new instance of the API Class.
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(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
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. |
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.
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. |
The result return after try to or connecting to the api endpoint.