Youtube api 如何使用API v3更新YouTube上的视频

Youtube api 如何使用API v3更新YouTube上的视频,youtube-api,Youtube Api,我试图在此页面上使用“试试看!”: 但是我得到了错误的请求。我应该在哪里设置要更新的视频的ID?更新视频标题或描述的请求格式是什么?请求格式是发送一个“视频资源”JSON数据包,如下所示: { "id": "GS9h8M3ep-M", "kind": "youtube#video", "etag": "\"MhkxP1IuK4vYJ-nhM3d9E49-2oU/HUmayeWdVX19XyvhE5c2RnbZjgA\"", "snippet": { "publishedAt": "20

我试图在此页面上使用“试试看!”:


但是我得到了错误的请求。我应该在哪里设置要更新的视频的ID?更新视频标题或描述的请求格式是什么?

请求格式是发送一个“视频资源”JSON数据包,如下所示:

{
"id": "GS9h8M3ep-M",
"kind": "youtube#video",
"etag": "\"MhkxP1IuK4vYJ-nhM3d9E49-2oU/HUmayeWdVX19XyvhE5c2RnbZjgA\"",
"snippet": {
    "publishedAt": "2012-11-10T09:36:49.000Z",
    "channelId": "UC070UP0rK7rShCW1x4B4bgg",
    "title": "Finding Ourselves: The Humanities as a Discipline",
    "description": "Lecture delivered by Geoffrey Harpham, of the National Humanities Center, at the inaugural event of the Brigham Young University Humanities Center.",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/GS9h8M3ep-M/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/GS9h8M3ep-M/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/GS9h8M3ep-M/hqdefault.jpg"
     }
    },
    "categoryId": "27",
    "tags": [
      "humanities",
      "Harpham",
      "BYU"
    ]
  }
}
{
 "id": "GS9h8M3ep-M",
 "kind": "youtube#video",
 "snippet": {
    "title": "I'm being changed.",
    "categoryId": "27",
    "tags": [
      "humanities",
      "Harpham",
      "BYU"
    ],
    "description": " can be changed, too, but if I'm not to be I still have to be included as I was before. I will be emptied out if omitted."
  }
 }
在执行更新时,只需发送“id”和“kind”值,在本例中还需要发送部分“snippet”。但是,请注意,对于可写属性——snippet.title、snippet.description、snippet.tags、snippet.categoryId和status.privacyStatus——忽略它们将使其恢复为默认值(“public”表示privacyStatus,空白表示其他4)。如果省略categoryId,则会导致错误的请求,因为这就像您将其设置为不在任何类别中一样,Youtube不允许视频没有类别(因此,将categoryId设为事实上必需的元素)。您还必须重新包含标记、说明和隐私状态(除非您希望它默认为public),以便它们不会被清除。因此,要修改标题,您需要包含代码段、其标题和类别ID,如下所示:

{
"id": "GS9h8M3ep-M",
"kind": "youtube#video",
"etag": "\"MhkxP1IuK4vYJ-nhM3d9E49-2oU/HUmayeWdVX19XyvhE5c2RnbZjgA\"",
"snippet": {
    "publishedAt": "2012-11-10T09:36:49.000Z",
    "channelId": "UC070UP0rK7rShCW1x4B4bgg",
    "title": "Finding Ourselves: The Humanities as a Discipline",
    "description": "Lecture delivered by Geoffrey Harpham, of the National Humanities Center, at the inaugural event of the Brigham Young University Humanities Center.",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/GS9h8M3ep-M/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/GS9h8M3ep-M/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/GS9h8M3ep-M/hqdefault.jpg"
     }
    },
    "categoryId": "27",
    "tags": [
      "humanities",
      "Harpham",
      "BYU"
    ]
  }
}
{
 "id": "GS9h8M3ep-M",
 "kind": "youtube#video",
 "snippet": {
    "title": "I'm being changed.",
    "categoryId": "27",
    "tags": [
      "humanities",
      "Harpham",
      "BYU"
    ],
    "description": " can be changed, too, but if I'm not to be I still have to be included as I was before. I will be emptied out if omitted."
  }
 }

太棒了…很高兴它成功了。如果你有机会将答案标记为正确的,它真的可以帮助其他人寻找类似的答案!我已经尝试过这样做,但出于某种原因,YouTube给了我一个“未选择过滤器”的选项消息。对可能出现的问题有什么想法吗?了解更多细节会很有帮助……您是使用API explorer还是在自己的web应用程序中编写请求?您选择的参数是什么?