【发布时间】:2014-12-16 10:41:24
【问题描述】:
我正在尝试向 YouTube API 发出 DELETE 请求,但是当我回显 curl_getinfo($ch, CURLINFO_HTTP_CODE) 时,它只显示 0 表示失败。
我检查了我的 API 密钥,这是正确的,访问代码也是如此,因为我正在使用刷新令牌获取访问令牌。
cURL 命令是否正确,还是我应该查看访问代码?
$url = "https://www.googleapis.com/youtube/v3/videos?id=".$vID."MY_API_KEY";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-type: application/json','Authorization : Bearer '.$access_token));
$result = curl_exec ($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
【问题讨论】:
标签: php curl youtube-api access-token api-key