了解新的 Picker API 和重要的 Library API 变更。如需了解详情,请点击
此处。
REST Resource: sessions
资源:PickingSession
表示用户会话,在此会话期间,用户可以使用 Google 相册选择照片和视频。
JSON 表示法 |
{
"id": string,
"pickerUri": string,
"pollingConfig": {
object (PollingConfig )
},
"expireTime": string,
"pickingConfig": {
object (PickingConfig )
},
"mediaItemsSet": boolean
} |
字段 |
id |
string
仅限输出。Google 为此会话生成的标识符。
|
pickerUri |
string
仅限输出。用于将用户重定向到 Google 相册(网页版)的 URI,以便用户选择当前会话的照片和视频。 如需成功查看此页面,用户必须在其网络浏览器中登录拥有此会话的 Google 账号。 出于安全原因,pickerUri 无法在 iframe 中打开。
|
pollingConfig |
object (PollingConfig )
仅限输出。应用在轮询 sessions.get 时应使用的建议配置。 只有在尚未为此会话选择媒体内容(即mediaItemsSet 为 false)。
|
expireTime |
string (Timestamp format)
仅限输出。对此会话(及其所选媒体内容)的访问权限到期的时间。 采用 RFC 3339 标准,生成的输出将始终在末尾带 Z,并使用 0、3、6 或 9 个小数位。不带“Z”的偏差时间也是可以接受的。示例:"2014-10-02T15:01:23Z" 、"2014-10-02T15:01:23.045123456Z" 或 "2014-10-02T15:01:23+05:30"
|
pickingConfig |
object (PickingConfig )
可选。此会话期间用户选择体验的照片选择配置。 这是客户端应用在调用 sessions.create 时指定的,事后无法修改(而无需创建新会话)。
|
mediaItemsSet |
boolean
仅限输出。如果设置为 true ,则表示已为此会话选择了媒体内容,您的应用可以通过 mediaItems.list 请求所选媒体内容的列表。
|
PollingConfig
JSON 表示法 |
{
"pollInterval": string,
"timeoutIn": string
} |
字段 |
pollInterval |
string (Duration format)
仅限输出。建议的轮询请求间隔时间。 该时长以秒为单位,最多包含九个小数位,以“s ”结尾。示例:"3.5s" 。
|
timeoutIn |
string (Duration format)
仅限输出。客户端应在多长时间后停止轮询。 值为 0 表示客户端应停止轮询(如果尚未停止)。 该时长以秒为单位,最多包含九个小数位,以“s ”结尾。示例:"3.5s" 。
|
PickingConfig
JSON 表示法 |
{
"maxItemCount": string
} |
字段 |
maxItemCount |
string (int64 format)
可选。用户在此会话期间可以选择的项数上限。如果未指定,则默认值为 2000。 如果未指定或设为 0,则最多可选择 2000 个项。高于 2000 的值将强制转换为 2000。负值将导致 INVALID_ARGUMENT 错误。
|
方法 |
|
生成一个新会话,用户可以在其中选择要授予第三方访问权限的照片和视频。 |
|
删除指定的会话。 |
|
检索指定会话的相关信息。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-10。
[null,null,["最后更新时间 (UTC):2025-03-10。"],[[["Google Photos Picker API provides sessions for users to select photos and videos."],["`PickingSession` resource represents the user's selection session, including a URI to redirect users to Google Photos for picking media."],["Applications can poll the API using the recommended `PollingConfig` to check for session updates and retrieve selected media items."],["Sessions have an expiration time and can be programmatically created, retrieved, and deleted using the API methods."]]],["A `PickingSession` represents a user's photo/video selection process in Google Photos, identified by a unique ID. It provides a `pickerUri` to direct users to Google Photos for media selection. `PollingConfig` defines API polling parameters with `pollInterval` and `timeoutIn`. A session expires at a specified `expireTime`, after which access ends. Once `mediaItemsSet` is true, selected media can be requested. Methods allow to `create`, `get` and `delete` sessions.\n"]]