Learn about the new Picker API and important Library API changes.
Details here.
開始使用 Library API
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Library API 可讓您與使用者的 Google 相簿圖庫中相片、影片和相簿互動,但有一個重要的重點:您只能存取及管理應用程式建立的內容。
事前準備
Library API 的主要用途
Library API 非常適合用於以下情況:
- 上傳及儲存媒體:將應用程式產生的相片和影片安全匯入使用者的 Google 相簿。
- 整理內容:建立及管理相簿,協助使用者整理應用程式相關媒體。
- 強化相片和相簿:運用標題、說明或位置資訊等充實內容,為媒體項目和相簿添加背景資訊。
- 存取應用程式建立的資料:擷取應用程式先前建立的相片、影片和相簿,並與這些內容互動。
一般 Library API 工作流程
雖然 Library API 提供多種功能,但常見的工作流程可能會涉及以下步驟:
上傳媒體:使用上傳端點,將相片或影片位元組安全地上傳到 Google 相簿。這個步驟會產生 uploadToken
。
建立媒體項目:使用 mediaItems.batchCreate
方法提供 uploadToken
,在使用者的媒體庫中建立媒體項目。
建立相簿 (選用):使用 albums.create
方法在使用者媒體庫中建立相簿,以便整理媒體項目。
管理相簿:
存取應用程式建立的媒體:
- 使用
mediaItems.get
或 mediaItems.batchGet
擷取特定媒體項目的詳細資料。
- 使用
mediaItems.search
搜尋應用程式建立的媒體項目。
- 使用
mediaItems.search
和專輯 ID,列出特定應用程式建立的專輯內的媒體項目。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-11-06 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-11-06 (世界標準時間)。"],[[["The Library API allows your application to interact with photos, videos, and albums in users' Google Photos libraries, but only for content created by your application."],["Key use cases include uploading/storing media, organizing content into albums, enhancing media with details, and accessing previously created app data."],["A typical workflow involves uploading media, creating media items, optionally creating and managing albums, and accessing the app-created media."],["Before starting, ensure the Library API aligns with your needs by reviewing the overview and configuring your app for API access."]]],["The Library API enables interaction with Google Photos, specifically for app-created content. Key actions include uploading media using an `uploadToken`, creating media items in the user's library, and optionally organizing them into albums. You can also manage albums by adding or removing media, adding enrichments, and retrieving album information. The API allows retrieval and searching of app-created media items. The first step before starting to use this API is to configure your application and ensure the Library API is suitable for your use case.\n"]]