commentThread 资源包含有关 YouTube 评论会话的信息,其中包括顶级评论和对该评论的回复(如果有)。commentThread 资源表示视频收到的评论。
顶级评论和回复实际上都是嵌套在 commentThread 资源中的 comment 资源。commentThread 资源并不一定包含评论的所有回复,如果您想要检索特定评论的所有回复,则需要使用 comments.list 方法。有些评论没有回复。
方法
对于 commentThreads 资源,该 API 支持以下方法:
- list
- 返回与 API 请求参数匹配的评论会话列表。 立即试用。
- insert
- 创建新的顶级评论。如需向现有评论添加回复,请改用 comments.insert方法。 立即试用。
资源表示法
JSON 结构显示了 commentThreads 资源的格式:
{
  "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
    ]
  }
}属性
下表定义了此资源中显示的属性:
| 属性 | |
|---|---|
| kind | string标识 API 资源的类型。其值将为 youtube#commentThread。 | 
| etag | etag此资源的 Etag。 | 
| id | stringYouTube 用来唯一标识评论会话的 ID。 | 
| snippet | objectsnippet对象包含有关评论会话的基本详细信息。它还包含线程的顶级注释,即comment资源。 | 
| snippet.channelId | string与会话中的评论相关联的 YouTube 频道。 snippet.videoId属性用于标识视频。 | 
| snippet.videoId | string评论所涉及的视频的 ID。 | 
| snippet.topLevelComment | object会话的顶级评论。该属性的值是 comment资源。 | 
| snippet.canReply | boolean此设置用于指明当前查看者是否可以回复会话串。 | 
| snippet.totalReplyCount | unsigned integer为回应顶级评论而提交的回复总数。 | 
| snippet.isPublic | boolean此设置用于指明是否所有 YouTube 用户都能看到该会话(包括其全部评论和评论回复)。 | 
| replies | objectreplies对象是一个容器,其中包含对评论的回复(如果存在)列表。replies.comments属性表示注释列表本身。 | 
| replies.comments[] | list顶级评论的一条或多条回复的列表。列表中的每一项都是一项 comment资源。此列表包含的回复数量有限,除非列表中的数量等于 snippet.totalReplyCount属性的值,否则回复列表将只是可用于顶级评论的回复总数的一部分。如需检索顶级评论的所有回复,您需要调用comments.list方法,并使用parentId请求参数标识您要检索回复的评论。 |