【问题标题】:YouTube Data API Comments IssuesYouTube 数据 API 评论问题
【发布时间】:2020-06-27 05:19:38
【问题描述】:

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

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

另一方面,如果我自己手动发布评论,它会到处显示,但我希望能够通过 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()

【问题讨论】:

  • 通过 YouTube API docs,您需要在 POST 请求中设置 "channelId"
  • 我已经更改了我的代码,因为您提到了 channelId,但它仍然没有向其他帐户显示 cmets。为什么有任何想法请@dspencer
  • 你得到了什么responsecommentThread 资源还是错误?
  • 我得到了 CommenThread 资源作为响应.. 但仍然没有显示该评论 @dspencer
  • 并且在 CommentThread 响应中.. 我总是得到 moderationStatus:heldForReview.. 你知道为什么会这样吗? @dspencer

标签: python youtube youtube-api youtube-data-api


【解决方案1】:

执行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,表示该评论尚未发布,因为它必须经过版主审核。

【讨论】:

  • 如果我对 20 个视频发表评论,那么每个回复都会有 sn-p.topLevelComment.sn-p.moderationStatus HoldForReview .... 为什么?你知道吗?@dspencer
猜你喜欢
  • 2017-11-29
  • 2010-12-26
  • 2013-09-20
  • 2021-04-26
  • 2013-11-21
  • 1970-01-01
  • 2022-01-05
  • 2015-07-10
  • 1970-01-01
相关资源
最近更新 更多