是否可以仅使用视频ID和密钥使用API V3删除YouTube视频?我一直收到关于“必需参数:部分”缺失的错误。我用Server和Browser api键试了一下这是我的代码:
// $youtube_id = the ID string and $key = the Key for browser applications
$delete_string = "https://www.googleapis.com/youtube/v3/videos?id=" . $youtube_id ."&key=" . $key;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$delete_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, true);
$output=curl_exec($ch);
curl_close($ch)
我收到错误:
{ "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Required parameter: part", "locationType": "parameter", "location": "part" } ], "code": 400, "message": "Required parameter: part" } }
答案 0 :(得分:1)
您错过了HTTP动词,也许这会导致此错误。
尝试添加此内容:
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
顺便说一下,也许你会想像google-api-php-client一样使用php api,所以你不必重新发明一切。