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 |
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 要求參數來找出要擷取回覆的註解。 |