activity
資源含有特定頻道或使用者在 YouTube 上所採取動作的相關資訊。活動動態消息所回報的動作包括影片評分、分享影片、將影片標示為最愛、上傳影片等等。每項 activity
資源都會指出動作類型、與動作相關的頻道,以及與動作相關的資源,例如評分或上傳的影片。
方法
這個 API 支援下列 activities
資源方法:
系統不再支援 activities.insert
方法。
資源表示法
下列 JSON 結構顯示了 activities
資源的格式:
{ "kind": "youtube#activity", "etag": etag, "id": string, "snippet": { "publishedAt": datetime, "channelId": string, "title": string, "description": string, "thumbnails": { (key): { "url": string, "width": unsigned integer, "height": unsigned integer } }, "channelTitle": string, "type": string, "groupId": string }, "contentDetails": { "upload": { "videoId": string }, "like": { "resourceId": { "kind": string, "videoId": string, } }, "favorite": { "resourceId": { "kind": string, "videoId": string, } }, "comment": { "resourceId": { "kind": string, "videoId": string, "channelId": string, } }, "subscription": { "resourceId": { "kind": string, "channelId": string, } }, "playlistItem": { "resourceId": { "kind": string, "videoId": string, }, "playlistId": string, "playlistItemId": string }, "recommendation": { "resourceId": { "kind": string, "videoId": string, "channelId": string, }, "reason": string, "seedResourceId": { "kind": string, "videoId": string, "channelId": string, "playlistId": string } }, "social": { "type": string, "resourceId": { "kind": string, "videoId": string, "channelId": string, "playlistId": string }, "author": string, "referenceUrl": string, "imageUrl": string }, "channelItem": { "resourceId": { } }, } }
屬性
下表列出顯示在這項資源中的屬性:
屬性 | |
---|---|
kind |
string 識別 API 資源的類型。值為 youtube#activity 。 |
etag |
etag 這項資源的 Etag。 |
id |
string YouTube 用來識別活動的專屬 ID。 |
snippet |
object snippet 物件包含活動的基本詳細資料,包括活動的類型和群組 ID。 |
snippet.publishedAt |
datetime 活動發生的日期和時間。這個值是以 ISO 8601 格式指定。 |
snippet.channelId |
string YouTube 用來識別與活動相關聯的頻道 ID。 |
snippet.title |
string 主要與活動相關聯的資源標題。 |
snippet.description |
string 主要與活動相關聯的資源說明。 |
snippet.thumbnails |
object 與活動主要與活動相關聯的縮圖圖片對應。地圖上每個物件的索引鍵是縮圖名稱,值則是包含縮圖其他資訊的物件。 |
snippet.thumbnails.(key) |
object 有效的鍵/值如下:
|
snippet.thumbnails.(key).url |
string 圖片網址。 |
snippet.thumbnails.(key).width |
unsigned integer 圖片的寬度。 |
snippet.thumbnails.(key).height |
unsigned integer 圖片的高度。 |
snippet.channelTitle |
string 進行活動的頻道標題 |
snippet.type |
string 資源說明的活動類型。 這個屬性的有效值如下:
|
snippet.groupId |
string 與活動相關聯的群組 ID。群組 ID 可用於識別與同一使用者和資源相關聯的使用者事件。舉例來說,如果使用者為影片評分並將同一部影片標示為收藏,則這些事件的項目會在使用者活動動態消息中具有相同的群組 ID。在您的使用者介面中,您可以將具有相同 groupId 值的事件分組,以免重複。 |
contentDetails |
object contentDetails 物件包含與活動相關聯的內容資訊。舉例來說,如果 snippet.type 值為 videoRated ,則 contentDetails 物件的內容會識別評分的影片。 |
contentDetails.upload |
object upload 物件包含上傳影片的相關資訊。只有在 snippet.type 為 upload 時,才會顯示這個屬性。 |
contentDetails.upload.videoId |
string YouTube 用來識別上傳影片的 ID。 |
contentDetails.like |
object like 物件含有獲得正面評分 (例如) 評分的資源相關資訊。只有在 snippet.type 為 like 時,才會顯示這個屬性。 |
contentDetails.like.resourceId |
object resourceId 物件包含用於識別已評分資源的資訊。 |
contentDetails.like.resourceId.kind |
string API 資源的類型。 |
contentDetails.like.resourceId.videoId |
string 如果評分資源為影片,YouTube 會使用這個 ID 明確識別影片。只有在 resourceId.kind 為 youtube#video 時,才會顯示這個屬性。 |
contentDetails.favorite |
object favorite 物件包含標示為最愛的影片的影片相關資訊。只有在 snippet.type 為 favorite 時,才會顯示這個屬性。 |
contentDetails.favorite.resourceId |
object resourceId 物件包含相關資訊,可用於識別已標示為收藏的資源。 |
contentDetails.favorite.resourceId.kind |
string API 資源的類型。 |
contentDetails.favorite.resourceId.videoId |
string YouTube 用來識別喜愛影片的 ID。只有在 resourceId.kind 為 youtube#video 時,才會顯示這個屬性。注意: activities.list 方法目前不會傳回新註解的資源。 |
contentDetails.comment |
object comment 物件包含收到註解的資源相關資訊。只有在 snippet.type 為 comment 時,才會顯示這個屬性。 |
contentDetails.comment.resourceId |
object resourceId 物件內含可識別註解相關資源的資訊。 |
contentDetails.comment.resourceId.kind |
string API 資源的類型。 |
contentDetails.comment.resourceId.videoId |
string YouTube 用來識別留言相關影片的專屬 ID。只有在 resourceId.kind 為 youtube#video 時,才會顯示這個屬性。 |
contentDetails.comment.resourceId.channelId |
string YouTube 用來識別留言相關頻道的專屬 ID。只有在 resourceId.kind 為 youtube#channel 時,才會顯示這個屬性。 |
contentDetails.subscription |
object subscription 物件含有使用者訂閱的頻道相關資訊。只有在 snippet.type 為 subscription 時,才會顯示這個屬性。 |
contentDetails.subscription.resourceId |
object resourceId 物件包含可識別使用者所訂閱資源的資訊。 |
contentDetails.subscription.resourceId.kind |
string API 資源的類型。 |
contentDetails.subscription.resourceId.channelId |
string YouTube 用來識別使用者訂閱的頻道的專屬 ID。只有在 resourceId.kind 為 youtube#channel 時,才會顯示這個屬性。 |
contentDetails.playlistItem |
object playlistItem 物件包含新播放清單項目的相關資訊。只有在 snippet.type 為 playlistItem 時,才會顯示這個屬性。 |
contentDetails.playlistItem.resourceId |
object resourceId 物件中包含資訊,可用於識別已新增至播放清單的資源。 |
contentDetails.playlistItem.resourceId.kind |
string API 資源的類型。 |
contentDetails.playlistItem.resourceId.videoId |
string YouTube 為加入播放清單的影片唯一識別的 ID。只有在 resourceId.kind 為 youtube#video 時,才會顯示這個屬性。 |
contentDetails.playlistItem.playlistId |
string YouTube 用來識別播放清單的專屬值。 |
contentDetails.playlistItem.playlistItemId |
string YouTube 用來辨識播放清單中各項目的專屬值。 |
contentDetails.recommendation |
object recommendation 物件含有建議資源的相關資訊。只有在 snippet.type 為 recommendation 時,才會顯示這個屬性。 |
contentDetails.recommendation.resourceId |
object resourceId 物件包含用於識別建議資源的資訊。 |
contentDetails.recommendation.resourceId.kind |
string API 資源的類型。 |
contentDetails.recommendation.resourceId.videoId |
string 如果建議資源為影片,YouTube 會使用這個 ID 來識別影片。只有在 resourceId.kind 為 youtube#video 時,才會顯示這個屬性。 |
contentDetails.recommendation.resourceId.channelId |
string 如果建議資源為頻道,YouTube 會使用這個 ID 來識別頻道。只有在 resourceId.kind 為 youtube#channel 時,才會顯示這個屬性。 |
contentDetails.recommendation.reason |
string 建議使用者使用資源的原因。 這個屬性的有效值如下:
|
contentDetails.recommendation.seedResourceId |
object seedResourceId 物件含有提出建議的資源相關資訊。 |
contentDetails.recommendation.seedResourceId.kind |
string API 資源的類型。 |
contentDetails.recommendation.seedResourceId.videoId |
string YouTube 用來識別影片的專屬 ID (如果建議是影片所促成)。只有在 seedResourceId.kind 為 youtube#video 時,才會顯示這個屬性。 |
contentDetails.recommendation.seedResourceId.channelId |
string YouTube 用來識別頻道的專屬 ID (如果最佳化建議是由特定頻道促成)。只有在 seedResourceId.kind 為 youtube#channel 時,才會顯示這個屬性。 |
contentDetails.recommendation.seedResourceId.playlistId |
string YouTube 用來識別播放清單的 ID (如果推薦是特定播放清單)。只有在 seedResourceId.kind 為 youtube#playlist 時,才會顯示這個屬性。 |
contentDetails.social |
object social 物件包含社群網路貼文的詳細資料。只有在 snippet.type 為 social 時,才會顯示這個屬性。 |
contentDetails.social.type |
string 社群網路的名稱。 這項屬性的有效值如下:
|
contentDetails.social.resourceId |
object resourceId 物件會封裝資訊,用於識別與社群網路貼文相關聯的資源。 |
contentDetails.social.resourceId.kind |
string API 資源的類型。 |
contentDetails.social.resourceId.videoId |
string 如果貼文提及影片,YouTube 會使用這個 ID 來明確識別社群網路貼文中的影片。只有在 social.resourceId.kind 屬性的值為 youtube#video 時,才會顯示這個屬性。 |
contentDetails.social.resourceId.channelId |
string 如果貼文提及頻道,YouTube 會使用這個 ID 來明確識別社群網路貼文中的主打頻道。只有在 social.resourceId.kind 屬性的值為 youtube#channel 時,才會顯示這個屬性。 |
contentDetails.social.resourceId.playlistId |
string 如果貼文提及播放清單,YouTube 會使用這個 ID 明確識別社群網路貼文中的精選播放清單。只有在 social.resourceId.kind 屬性的值為 youtube#playlist 時,才會顯示這個屬性。 |
contentDetails.social.author |
string 社群網路貼文的作者。 |
contentDetails.social.referenceUrl |
string 社群網路貼文的網址。 |
contentDetails.social.imageUrl |
string 文章作者的圖片。 |
contentDetails.channelItem |
object channelItem 物件包含新增到頻道的資源相關詳細資料。只有在 snippet.type 為 channelItem 時,才會顯示這個屬性。 |
contentDetails.channelItem.resourceId |
object resourceId 物件內含用來識別新增至頻道的資源的資訊。 |