gpt4 book ai didi

php - 通过curl在youtube视频上发表评论

转载 作者:行者123 更新时间:2023-12-03 05:31:52 25 4
gpt4 key购买 nike

我正在做一个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." } }

请帮帮我。

最佳答案

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

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

关于php - 通过curl在youtube视频上发表评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35393313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com