【问题标题】:Post comment on youtube video by curlcurl 在 youtube 视频上发表评论
【发布时间】:2016-05-25 09:58:24
【问题描述】:

我正在开发一个 youtube 应用项目。但我不能对任何视频发表评论。我正在使用 curl 和 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." } }

请帮帮我。

【问题讨论】:

    标签: php curl youtube youtube-api youtube-data-api


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-13
      • 2015-12-13
      • 2012-03-22
      • 2012-11-07
      • 2015-03-03
      • 2015-09-26
      • 2013-11-21
      • 1970-01-01
      相关资源
      最近更新 更多