问题描述:

I am trying to send a GET request to a REST API with a custom header, and I've followed tutorials and looked on here, but nothing I tried has worked. Am I missing something from this code?

<?php

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, "https://manager.gimbal.com/api/beacons/");

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$headers = array(

'Content-type: application/json',

'authorization: Token token={token}',

);

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($curl);

curl_close($curl);

print($result);

?>

I have the correct token, it worked when I used a REST client.

相关阅读:
Top