18 lines
333 B
PHP
18 lines
333 B
PHP
<?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();
|
|
|
|
}
|