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 列出特定应用创建的影集内的媒体内容。
后续步骤
- 查看参考文档:浏览详细的库 API 参考文档,了解所有可用的方法和参数。
- 试用示例:查看我们的示例,了解 Library API 的实际运用并获取集成灵感。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-11-06。
[null,null,["最后更新时间 (UTC):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"]]