YouTube 服務
您可以在 YouTube 服務中使用 YouTube Data API 和 YouTube Live Streaming API 在 Apps Script 中。這個 API 可讓使用者管理影片、播放清單、頻道和直播活動。
參考資料
如要進一步瞭解這項服務,請參閱下列參考說明文件:
與 Apps Script 中的所有進階服務一樣,YouTube 服務會使用與公開 API 相同的物件、方法和參數。詳情請參閱「如何決定方法簽章」。
如要回報問題或尋求其他支援,請參閱對應的支援頁面:
程式碼範例
以下程式碼範例使用 YouTube Data API 的 第 3 版。
依關鍵字搜尋
這個函式會搜尋有關狗的影片,然後記錄影片 ID 和標題。請注意,這個範例會將結果數量限制在 25 個。如要傳回更多結果,請傳遞額外參數,如 YouTube Data API 參考說明文件所示。
擷取上傳內容
此函式會擷取使用者上傳的影片。這項服務會透過下列步驟執行這項操作:
- 擷取使用者的頻道
- 擷取使用者的
uploads
播放清單
- 逐一檢查這個播放清單,並記錄影片 ID 和標題
- 如果有下一頁結果,請擷取該頁面,然後返回步驟 3
訂閱頻道
這個範例會讓使用者訂閱 YouTube 上的 Google Developers 頻道。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-21 (世界標準時間)。
[null,null,["上次更新時間:2024-12-21 (世界標準時間)。"],[[["The YouTube service in Apps Script allows you to manage videos, playlists, channels, and live events using the YouTube Data API and YouTube Live Streaming API."],["This is an advanced service that needs to be enabled before use within your Apps Script project."],["Sample code is provided to demonstrate searching for videos, retrieving user uploads, and subscribing to channels using the API."],["Refer to the YouTube Data API and YouTube Live Streaming API reference documentation for detailed information and further functionalities."]]],[]]