php-spark/runtime/http.php

18 lines
333 B
PHP
Raw Permalink Normal View History

<?php
function fetch(string $url, array $options=[], bool $returnResponse=false) {
$client = new GuzzleHttp\Client();
$method = $options['method'] ?? 'GET';
$response = $client->request($method, $url, $options);
if ($returnResponse) {
return $response;
}
return (string)$response->getBody();
}