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 要求參數,找出您想擷取的註解。 |