Network and HTTP
HTTP¶
query(array form_values) : string¶
Converts an associative array into a form-style string, used for e.g. application/x-www-form-urlencoded
requests or HTTP query strings.
request(string url, string body, string method = 'GET', array headers, bool override = false, timeout = 5) : array¶
Sends a HTTP request and returns an array with the following keys containing response data:
content
(contains a cURL error message in case of an error)status
(null
in case of an error)headers
url
The headers should be an array of strings, for example:
To get a JSON document, validate if valid JSON, and get a property:
response = request('https://example.com')
decoded = json_decode(response['content'])
if (decoded) {
value = decoded['value']
}
If override
is set to true, none of the content from the original request is included (e.g. query strings, headers, content.)
url_decode(string value) : string¶
Returns an URL-decoded version of value.
url_encode(string value) : string¶
Returns an URL-encoded version of value.