YouTube 数据 API 评论问题

YouTube Data API Comments Issues

我正在使用他们在其网站上提供的示例代码测试 youtube API,并尝试仅通过视频 ID post 对视频发表评论。

一切正常,当我使用我的帐户访问该页面时,我会在那里看到我的评论,除非我使用不同的帐户访问该特定视频时找不到我的评论或只是在隐身模式下打开 youtube window 它没有出现。

另一方面,如果我自己手动 post 评论,它会出现在任何地方,但我希望能够通过 API.

而且我已经尝试了 40-50 次。

我的代码:-

def insert_new_comment(youtube, video_id, comment,channelId):
    request = youtube.commentThreads().insert(
        part="snippet",
        body={
            "snippet": {
                "channelId": channelId,
                "videoId": video_id,
                "topLevelComment": {
                    "snippet": {
                        "textOriginal": comment
                    }
                }
            }
        }
    )
    response = request.execute()

执行response = request.execute()后,应该检查注释插入的结果。如果请求成功,应返回新评论的 commentThread 资源。此资源应类似于:

{
  "kind": "youtube#commentThread",
  "etag": etag,
  "id": string,
  "snippet": {
    "channelId": string,
    "videoId": string,
    "topLevelComment": comments Resource,
    "canReply": boolean,
    "totalReplyCount": unsigned integer,
    "isPublic": boolean
  },
  "replies": {
    "comments": [
      comments Resource
    ]
  }
}

在这种情况下,返回的 commentThread 包含一个 snippet.topLevelComment.snippet.moderationStatus 元素,设置为 heldForReview,表示评论尚未发布,因为它必须接受审核通过主持人。