YouTube 即將淘汰頻道公告功能。因此,
activities.insert
方法將遭淘汰,activities.list
方法也會停止傳回頻道公告。這些異動將於 2020 年 5 月 18 日當天或之後在 API 中生效。詳情請參閱 YouTube 說明中心。以下範例說明如何使用 YouTube Data API (第 3 版) 執行與使用者活動相關的功能。
擷取管道活動清單
如要擷取與特定管道相關的事件清單,請使用下列任一方法來識別管道,然後呼叫 activities.list
方法:
-
將
mine
參數值設為true
,即可擷取目前已經驗證使用者的活動清單。您的要求必須使用 OAuth 2.0 授權。https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.activities.list? part=snippet,contentDetails &mine=true
-
將
channelId
參數設為 YouTube 頻道 ID,即可明確識別要擷取活動清單的頻道。這個範例將channelId
參數設為UCK8sQmJBp8GCxrOtXWBpyEA
,這也是 Google 官方 YouTube 頻道的 ID。https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.activities.list? part=snippet,contentDetails &channelId=UCK8sQmJBp8GCxrOtXWBpyEA
擷取訂閱活動清單
訂閱活動是指與已驗證使用者訂閱的頻道相關聯的事件。如要擷取目前已驗證使用者的訂閱活動清單,請呼叫 activities.list
方法,並將 home
參數的值設為 true
。要求必須使用 OAuth 2.0 授權。
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.activities.list? part=snippet,contentDetails &home=true