feat: add post() function
initial commit
Utilities related to http.
Install with composer:
composer require thirdplace/http:dev-main
Install manually:
wget https://git.sr.ht/~thirdplace/http/blob/main/http.php
Example usage:
<?php
try {
$result = Thirdplace\get('https://example.com', ['timeout' => 3]);
} catch (\RuntimeException $e) {
exit("hmm\n");
}
if ($result['code'] === 200) {
print $result['body'];
} else {
print "oh\n";
}
Returns an associative array with code
and body
.
Uses curl. Throws \RuntimeException
on curl failure.
function get(string $url, array $config = []): array