Comments

comment 資源含有單一 YouTube 留言的相關資訊。comment 資源可以代表對影片或頻道的留言。此外,該留言可能是頂層留言或頂層留言的回覆。

方法

這個 API 支援下列 comments 資源方法:

list
傳回符合 API 要求參數的註解清單。立即試用
插入
回覆現有註解。注意:如要建立頂層註解,請使用 commentThreads.insert 方法。立即試用
更新
修改註解。 立即試用
刪除
刪除留言。 立即試用
setModerationStatus
設定一或多則留言的管理狀態。API 要求必須獲得留言相關頻道或影片擁有者的授權。立即試用
markAsSpam
注意:這個方法已淘汰,不再受支援。
指出來電者的想法,指出有一或多則留言應標記為垃圾內容。

資源表示法

下列 JSON 結構顯示 comments 資源的格式:

{
  "kind": "youtube#comment",
  "etag": etag,
  "id": string,
  "snippet": {
    "authorDisplayName": string,
    "authorProfileImageUrl": string,
    "authorChannelUrl": string,
    "authorChannelId": {
      "value": string
    },
    "channelId": string,
    "textDisplay": string,
    "textOriginal": string,
    "parentId": string,
    "canRate": boolean,
    "viewerRating": string,
    "likeCount": unsigned integer,
    "moderationStatus": string,
    "publishedAt": datetime,
    "updatedAt": datetime
  }
}

屬性

下表定義了這項資源中顯示的屬性:

屬性
kind string
識別 API 資源的類型。值為 youtube#comment
etag etag
這項資源的 Etag。
id string
YouTube 用來識別留言的專屬 ID。
snippet object
snippet 物件包含註解的基本詳細資料。
snippet.authorDisplayName string
留言發布者的顯示名稱。
snippet.authorProfileImageUrl string
留言者的顯示圖片網址。
snippet.authorChannelUrl string
留言作者的 YouTube 頻道網址 (如有)。
snippet.authorChannelId object
這個物件會封裝留言作者的 YouTube 頻道相關資訊 (如有)。
snippet.authorChannelId.value string
留言作者的 YouTube 頻道 ID (如有)。
snippet.channelId string
與留言相關聯的 YouTube 頻道 ID。
snippet.textDisplay string
留言的文字。該文字可用純文字或 HTML 格式擷取。(comments.listcommentThreads.list 方法都支援 textFormat 參數,用來指定所選的文字格式)。

即使是純文字可能與原始留言文字不同,例如以影片標題取代影片連結。
snippet.textOriginal string
留言最初發布或上次更新的原始文字。只有在已驗證使用者的身分是留言者,系統才會傳回原始文字。
snippet.parentId string
家長留言的專屬 ID。只有在評論被提交為其他留言時,才會設定這個屬性。
snippet.canRate boolean
這項設定可用來指定目前的觀眾能否為留言評分。
snippet.viewerRating string
觀眾對這則留言的評分。這個屬性無法識別 dislike 評分,但此行為隨時可能變更。在這段期間內,如果觀眾對留言給予正面評價,這個值會是 like。在其他情況下,這個值為 none,包括使用者給予負面評分,或未給該留言評分的使用者。

這個屬性的有效值如下:
  • like
  • none
snippet.likeCount unsigned integer
留言獲得的喜歡總數 (正面評分)。
snippet.moderationStatus string
留言的管理狀態。只有在 API 要求獲得頻道擁有者或要求留言之影片的授權時,才會傳回這個屬性。此外,如果 API 要求使用 id 篩選器參數,則未設定這項屬性。

這個屬性的有效值如下:
  • heldForReview
  • likelySpam
  • published
  • rejected
snippet.publishedAt datetime
留言在公開發布的日期和時間。這個值是以 ISO 8601 格式指定。
snippet.updatedAt datetime
留言上次更新的日期和時間。這個值是以 ISO 8601 格式指定。