通过卷曲在YouTube视频上发表评论


Post comment on youtube video by curl

我正在做一个YouTube应用程序项目。但我不能对任何视频发表评论。我正在使用卷曲和 php。我已经正确放置了所有功能,但显示错误如果我正在使用

curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);

$data_json在哪里

    {
    "snippet": {
  "topLevelComment": {
   "snippet": {
    "videoId": "<?php echo $videoid; ?>",
    "textOriginal": "<?php echo $comment; >"
   }
  }
 }
}
 { "error": { "errors": [ { "domain": "global", "reason": "parseError",                                   
 "message": "This API does not support parsing form-encoded input." } ],  
 "code":    400, "message": "This API does not support parsing form-encoded
 input." } }

请帮帮我。

您需要

提及您的content-type标头,以便youtube知道您要发送的内容。默认情况下,您现在正在使用form-encoded输入。

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));