commentThread
資源包含 YouTube 留言串的相關資訊,其中包含該留言的頂層留言和回覆 (如果有的話)。commentThread
資源代表影片的留言。
頂層留言和回覆都是以巢狀方式嵌入 commentThread
資源中的 comment
項資源。commentThread
資源不一定會包含註解的所有回覆。如果您要擷取特定留言的所有回覆,就必須使用 comments.list
方法。部分留言尚未回覆。
方法
這個 API 支援下列 commentThreads
資源方法:
- list
- 傳回符合 API 要求參數的註解執行緒清單。立即試用。
- 插入
- 建立新的頂層留言。如要為現有的註解新增回覆,請改用
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 |
string YouTube 用來識別留言串的專屬 ID。 |
snippet |
object snippet 物件包含留言執行緒的基本詳細資料。也會包含執行緒的頂層註解,也就是 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 |
object replies 物件是一個容器,包含對註解的回覆清單 (如果有的話)。replies.comments 屬性代表註解本身的清單。 |
replies.comments[] |
list 頂層留言的一或多個回覆清單。清單中的每個項目都是 comment 資源。這份清單只包含回覆數目有限,除非清單中的項目數等於 snippet.totalReplyCount 屬性的值,否則回覆清單只會是頂層留言可用的回覆總數的一部分。如要擷取頂層註解的所有回覆,您必須呼叫 comments.list 方法並使用 parentId 要求參數,找出要擷取回覆的註解。 |