HttpClient
class HttpClient (View source)
Methods
HttpClient Constructor.
Set the base url
Attach file(s) to the request
Set the User-Agent header
Configure client to accept and send JSON data
Add custom HTTP headers
Set HTTP authentication credentials
Set Basic HTTP authentication
Set Bearer token authentication
Set the maximum time the request is allowed to take
Set the maximum time to wait for a connection
Disable SSL certificate verification
Details
__construct(string|null $base_url = null)
HttpClient Constructor.
void
setBaseUrl(string $url)
Set the base url
Response
get(string $url, array $data = [])
Make GET request
Response
post(string $url, array $data = [])
Make POST request
Response
put(string $url, array $data = [])
Make PUT request
Response
delete(string $url, array $data = [])
Make DELETE request
HttpClient
addAttach(string|array $attach)
Attach file(s) to the request
HttpClient
setUserAgent(string $user_agent)
Set the User-Agent header
HttpClient
acceptJson()
Configure client to accept and send JSON data
HttpClient
withHeaders(array $headers)
Add custom HTTP headers
HttpClient
auth(string $username, string $password)
Set HTTP authentication credentials
HttpClient
basicAuth(string $key, string $secret)
Set Basic HTTP authentication
HttpClient
bearerAuth(string $token)
Set Bearer token authentication
HttpClient
timeout(int $seconds)
Set the maximum time the request is allowed to take
HttpClient
connectTimeout(int $seconds)
Set the maximum time to wait for a connection
HttpClient
disableSslVerification()
Disable SSL certificate verification
Warning: This should only be used in development environments