无法通过API删除对Youtube视频的评论

时间:2017-04-25 13:21:12

标签: youtube-api youtube-data-api

我试图在this video上删除后续评论 z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo 但响应代码为400.我使用了频道管理员的令牌{em> https://www.googleapis.com/auth/youtube.force-ssl documentation要求的范围。

请求是:

DELETE https://www.googleapis.com/youtube/v3/comments?id=z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo&alt=json

{
    "query_params": { 
        "id": "z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo",
        "alt": "json"
    }
}

回应:

{
 "error": {
  "errors": [
   {
    "domain": "youtube.comment",
    "reason": "processingFailure",
    "message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid.",
    "locationType": "parameter",
    "location": "id"
   }
  ],
  "code": 400,
  "message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid."
 }
}

请求有什么问题?

该令牌调试信息:

{
    issued_to: "493985796851.apps.googleusercontent.com",
    audience: "493985796851.apps.googleusercontent.com",
    user_id: "109704411339866376304",
    scope: "https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtube.upload",
    expires_in: 2452,
    access_type: "offline"
}

1 个答案:

答案 0 :(得分:1)

您无法删除评论的原因是您正在使用Comments.delete删除其他用户撰写的评论。 Comments.delete只会在您的视频中删除您自己的评论。

要删除其他用户的评论,请使用Comments.setModerationStatus并将moderationStatus设置为“rejected”。

所以请重复你所做的事,但这一次使用Comments.setModerationStatus。链接中有一个Try-it用于测试目的。