当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Sending GET request to REST API with custom header

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: