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 物件包含的資訊可用來識別已新增至管道的資源。 |