我正在尝试为 datadog api 编写一个 php curl,但它返回内部错误。这在 bash 脚本中工作,但在 phpcurl 中转换时抛出错误。有人可以帮我解决这个问题。
$data = [
'tags' => '[env:prod]'
];
$headers = [
'Accept: application/json',
'Content-Type: application/json'
];
$tagUrl="https://app.datadoghq.com/api/v1/tags/hosts/".$host."?api_key=".$api_key."&application_key=".$app_key;
$http_method='POST';
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $tagUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
$out=curl_exec($ch);