dongtanxi5676756 2016-09-04 04:40
浏览 38

使用自定义标头向REST API发送GET请求

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 shape_predictor_68_face_landmarks.dat
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制