使用 youtube 数据 api v3 删除评论?

Remove a comment using the youtube data api v3?

作为频道所有者,我正在尝试删除其他用户在我的视频和我的讨论部分中发表的评论。

我在 api 文档中找不到有关该函数的任何信息。我可以使用评论 ID 调用删除功能,但它仅适用于登录 api 的用户发布的评论。我想调用这张图片中概述的相同函数,它在 youtube 上可用:

I need to call this remove function from the API

这里 the link 评论 api。

您将使用 Comments.delete 这将要求您传递 commentId 以删除特定评论。获取commentId的方法有很多种,我用的是这个URI GET请求:

https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId={VIDEO_ID}&key={API_KEY}

您将收到如下回复:

"items": [
  {
   "kind": "youtube#commentThread",
   "etag": "\"5C5HHOaBSHC5ZXfkrT4ZlRCi01A/wQo7nKuPMjPTCeeV9ofDLff8KhY\"",
   "id": "z12ojxq5qwjlulz4o04cc5vxauuaubkbovk0k",
   "snippet": {
    "videoId": "Ez4nKZ2BeTU",
    "topLevelComment": {
     "kind": "youtube#comment",
     "etag": "\"5C5HHOaBSHC5ZXfkrT4ZlRCi01A/Ifn8tdeFUJiclXThCp44Cib6-cU\"",
     "id": "z12ojxq5qwjlulz4o04cc5vxauuaubkbovk0k", //this is the commentId you will use to delete the comment
     "snippet": {
      "authorDisplayName": "...",
      "authorProfileImageUrl": "...",
      "authorChannelUrl": "...",
      "authorChannelId": {
       "value": "..."
      },
      "videoId": "Ez4nKZ2BeTU",
      "textDisplay": "deleteme\ufeff", //this is my comment which I would like to delete
      ...

使用 commentId 并将其传递给 Comments.delete Try-it 以删除评论。如果成功,它将 return 一个 204 状态。这就是概念。希望这有帮助。

我从Google得到的回复:

"You cannot delete comments that have not been made by your own account. To remove and moderate comments from other users on videos that you own please use the setModerationStatus API documented here: https://developers.google.com/youtube/v3/docs/comments/setModerationStatus"

您可以将审核状态设置为拒绝,它将具有相同的功能。