Version: v0.6.0 - Beta.  We welcome contributors & feedback.  THanks!

Net.httpRequest

Net.httpRequest($method, $url, $data = '', $headers = {})

Description

Send an HTTP request and get the body of the response as a string.

$method is the HTTP method. (e.g. 'GET', 'POST')

$url must be a URL TypeString.

$data can be a string containing the raw request body, or a Map, which will be converted to a URL-encoded string.

$headers is an optional map of HTTP request headers.

// Basic call
$content = Net.httpRequest('GET', url'http://example.com');

// With headers
$headers = {
    'Cookie': 'sessionId=1234; otherCookie=1;'
};
$content2 = Net.httpRequest('POST', url'http://example.com', { myVar: 1 }, headers);