我使用curl与YouTube API v3创建一个广播,修改视频标题等,没有任何问题。我的问题是,当我试图添加一个缩略图到一个视频使用医生们从谷歌。
以下是基于安全原因更改密钥的示例:
curl --request POST -v \
"https://youtube.googleapis.com/youtube/v3/thumbnails/set\
?videoId=RoZypUhZY04\
&uploadType=media\
&key=mykey" \
--header 'Authorization: Bearer my_access_token' \
--header 'Content-Type: image/jpeg'\
-F 'file=@/Users/adviner/Projects/Prototypes/VendorAPI/source/YouTube/YouTube-BOS.jpg'\
-F 'filename=YouTube-BOS.jpg'
我试过:
-F 'image=@/Users/adviner/Projects/Prototypes/VendorAPI/source/YouTube/YouTube-BOS.jpg'\
在文档中,它说要使用以下URL发布图像:
https://www.googleapis.com/upload/youtube/v3/thumbnails/set
但是,当您查看它说要使用的示例时:
https://youtube.googleapis.com/youtube/v3/thumbnails/set
我尝试了这两种方法,并且看起来这些图片已经正确上传了,但是我得到了以下错误:
对于第一个URL:https://www.googleapis.com/upload/youtube/v3/thumbnails/set
{
"error": {
"code": 400,
"message": "Media type 'image/jpeg; boundary=------------------------136ebfc0c8146cb8' is not supported. ",
"errors": [
{
"message": "Media type 'image/jpeg; boundary=------------------------136ebfc0c8146cb8' is not supported. ",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
使用URL:https://youtube.googleapis.com/youtube/v3/thumbnails/set时
{
"error": {
"code": 400,
"message": "The request does not include the image content.",
"errors": [
{
"message": "The request does not include the image content.",
"domain": "youtube.thumbnail",
"reason": "mediaBodyRequired",
"location": "body",
"locationType": "other"
}
]
}
}
对我错过了什么有什么想法吗?
谢谢
发布于 2021-02-18 17:54:46
您必须使用规范文件上的URL
https://www.googleapis.com/upload/youtube/v3/thumbnails/set
。
在我的经验中,示例代码页并不是百分之百可靠的(例如,Videos.insert
API端点受到相同问题的影响)。
您必须发出以下curl
调用:
curl --request POST -v \
"https://www.googleapis.com/upload/youtube/v3/thumbnails/set\
?videoId=RoZypUhZY04\
&uploadType=media" \
--header 'Authorization: Bearer my_access_token' \
--header 'Content-Type: image/jpeg'\
--data-binary '@/Users/adviner/Projects/Prototypes/VendorAPI/source/YouTube/YouTube-BOS.jpg'
注意,上面的调用没有使用两个-F
选项(表单选项),而是使用了一个--data-binary
选项,其参数以@
开头,以表明参数的其余部分是文件名。
https://stackoverflow.com/questions/66264652
复制相似问题