class HttpClient (View source)

Methods

__construct(string|null $base_url = null)

HttpClient Constructor.

void
setBaseUrl(string $url)

Set the base url

get(string $url, array $data = [])

Make GET request

post(string $url, array $data = [])

Make POST request

put(string $url, array $data = [])

Make PUT request

delete(string $url, array $data = [])

Make DELETE request

addAttach(string|array $attach)

Attach file(s) to the request

setUserAgent(string $user_agent)

Set the User-Agent header

acceptJson()

Configure client to accept and send JSON data

addHeaders(array $headers)

Add custom HTTP headers

Details

__construct(string|null $base_url = null)

HttpClient Constructor.

Parameters

string|null $base_url

void setBaseUrl(string $url)

Set the base url

Parameters

string $url

Return Value

void

Response get(string $url, array $data = [])

Make GET request

Parameters

string $url
array $data

Return Value

Response

Exceptions

Exception

Response post(string $url, array $data = [])

Make POST request

Parameters

string $url
array $data

Return Value

Response

Exceptions

Exception

Response put(string $url, array $data = [])

Make PUT request

Parameters

string $url
array $data

Return Value

Response

Exceptions

Exception

Response delete(string $url, array $data = [])

Make DELETE request

Parameters

string $url
array $data

Return Value

Response

Exceptions

Exception

HttpClient addAttach(string|array $attach)

Attach file(s) to the request

Parameters

string|array $attach

Return Value

HttpClient

HttpClient setUserAgent(string $user_agent)

Set the User-Agent header

Parameters

string $user_agent

Return Value

HttpClient

HttpClient acceptJson()

Configure client to accept and send JSON data

Return Value

HttpClient

HttpClient addHeaders(array $headers)

Add custom HTTP headers

Parameters

array $headers

Return Value

HttpClient