I’m trying to access the Fibery API via PHP using the Leaf PHP 3.0 framework. I’ve first tested the API call I’m trying to make in Postman and got that working. Now I’m converting to php and running into an 401 Unauthorized response.
Am I missing something simple? If not I’ll dive into the support community of Leaf PHP.
Leaf docs can be found here: Leaf Fetch | Leaf PHP
The code (
$res = Fetch::request([
"url" => 'https://myurl.fibery.io/api/commands',
"method" => "POST",
"headers" => [
"Authorization" => 'Token my.token',
"Content-Type" => "application/json"
],
"data" => ['[{ "command": "fibery.schema/query" }]'],
]);
The response:
stdClass Object
(
[data] =>
[status] => 401
[headers] => Array
(
[0] => HTTP/2 401
[date] => Mon, 05 Feb 2024 14:41:57 GMT
[content-length] => 12
[x-kong-response-latency] => 6
)
[request] => Array
(
[url] => https://myurl.fibery.io/api/commands
[method] => POST
[baseUrl] =>
[headers] => Array
(
[Authorization] => Token my.token
[Content-Type] => application/json
)
[params] => Array
(
)
[data] => Array
(
[0] => [{ "command": "fibery.schema/query" }]
)
[timeout] => 0
[withCredentials] =>
[auth] => Array
(
)
[responseType] => json
[responseEncoding] => utf8
[xsrfCookieName] => XSRF-TOKEN
[xsrfHeaderName] => X-XSRF-TOKEN
[maxContentLength] => 2000
[maxBodyLength] => 2000
[maxRedirects] => 5
[socketPath] =>
[proxy] => Array
(
)
[decompress] => 1
[rawResponse] =>
[verifyHost] => 1
[verifyPeer] => 1
[curl] => Array
(
)
)
)