add token auth

This commit is contained in:
Martz
2023-02-16 22:36:16 +01:00
parent 2b8639223b
commit 9224293de2

View File

@@ -19,6 +19,13 @@ class Collection
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url . "/api/collections/".$this->collection."/records"); curl_setopt($ch, CURLOPT_URL, $this->url . "/api/collections/".$this->collection."/records");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(self::$token != ''){
$headers = array(
'Content-Type:application/json',
'Authorization: '.self::$token
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$output = curl_exec($ch); $output = curl_exec($ch);
curl_close($ch); curl_close($ch);