0

我正在尝试在 php 中使用 calendy API 我使用以下代码来检查身份验证令牌

<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://calendly.com/api/v1/echo");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "X-TOKEN: <Token-code>",// My Token code here
  ));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch , CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch , CURLOPT_POST, true);
curl_setopt($ch , CURLOPT_POSTFIELDS, $curl_post_data);
curl_setopt($ch , CURLOPT_SSL_VERIFYPEER, false); //IMP if the url has https and you don't want to verify source certificate
$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);

print_r($result);?> 

但我收到错误消息 404 未经授权

{
  "type": "authentication_error",
  "message": "Invalid token"
}
4

1 回答 1

0

任何使用 Calendy API 的人都可以这样使用

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://calendly.com/api/v1/echo");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "X-TOKEN: TOKE-HERE",
  ));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch , CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch , CURLOPT_POST, true);
curl_setopt($ch , CURLOPT_POSTFIELDS, $curl_post_data);
curl_setopt($ch , CURLOPT_SSL_VERIFYPEER, false); //IMP if the url has https and you don't want to verify source certificate
$result = curl_exec($ch);
echo $result;
curl_close ($ch);
于 2017-03-02T11:04:07.910 回答