class UrlFetch (View source)

Methods

fetch(string $url, string $requestMethod = 'GET', array $headers = [], string $payload = '', bool $allowTruncated = true, bool $followRedirects = true, float $deadline = 0.0, bool $validateCertificate = false)

Fetches a URL.

Details

URLFetchResponse fetch(string $url, string $requestMethod = 'GET', array $headers = [], string $payload = '', bool $allowTruncated = true, bool $followRedirects = true, float $deadline = 0.0, bool $validateCertificate = false)

Fetches a URL.

Parameters

string $url Specifies the URL.
string $requestMethod Optional, The HTTP method. URLs are fetched using one of the following HTTP methods: - GET - POST - HEAD - PUT - DELETE - PATCH
array $headers Optional, array containing values in the format of {key => value} pairs.
string $payload Optional, payload for a URL Request when using POST, PUT, and PATCH requests.
bool $allowTruncated Optional, specify if content is truncated.
bool $followRedirects Optional, specify if redirects are followed.
float $deadline Optional, the timeout for the request in seconds.
bool $validateCertificate Optional, If set to true, requests are not sent to the server unless the certificate is valid and signed by a trusted CA.

Return Value

URLFetchResponse Returns URLFetchResponse object upon success, else throws application error.

Exceptions

Exception If UrlFetchRequest has an application failure, if illegal web protocol used, or if content is illegally truncated.