first version, no prod ready

This commit is contained in:
Jonathan Martz
2025-06-24 21:43:34 +02:00
parent 81e8486870
commit a21e474749
22 changed files with 566 additions and 693 deletions

31
src/HttpClient.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
namespace PocketBase;
class HttpClient
{
public function doRequest(string $url, string $method, $bodyParams = [], ?string $token = null): string
{
$ch = curl_init();
if ($token != '') {
$headers = array(
'Content-Type:application/json',
'Authorization: ' . $token
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
if ($bodyParams) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyParams);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
}