【问题标题】:Cannot delete comment on Youtube video via API无法通过 API 删除对 Youtube 视频的评论
【发布时间】:2017-04-25 13:21:11
【问题描述】:

我正在尝试删除this video 上的以下评论 z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo,但响应代码是 400。我正在使用频道管理员的令牌 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"
}

【问题讨论】:

  • 您似乎无权删除该评论。您确定您的访问令牌是有效的并且用于正确的渠道吗?
  • 我想是的。我在问题中添加了令牌信息,它需要“force-ssl”范围,用户 109704411339866376304 是频道的所有者。

标签: youtube-api youtube-data-api


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-21
    • 2017-10-04
    • 2010-12-13
    • 2016-09-01
    相关资源
    最近更新 更多