Learn about the new Picker API and important Library API changes.
Details here.
Picker API を使ってみる
Picker API を使用すると、ユーザーは Google フォトのライブラリから写真や動画を選択し、アプリと共有できます。
始める前に
Picker API のフロー
Picker API の仕組みの概要は次のとおりです。
OAuth トークンの確認: Picker API フローを開始する前に、ユーザーの有効な OAuth 2.0 アクセス トークンを確認します。トークンがない場合、OAuth 2.0 認可フローを開始してトークンを取得します。
セッションを作成する: Picker API を呼び出して新しいセッションを作成し、プロセスを開始します。この呼び出しは、一意の pickerUri
を返します。
Google フォト アプリにユーザーを誘導する: pickerUri
をユーザーに提供します(クリック可能なリンクまたは QR コードのいずれか)。この URL により、Google フォト アプリが安全に開きます。
ユーザーがメディア アイテムを選択する: Google フォト アプリ内で、ユーザーはライブラリをブラウジングし、アプリと共有する写真や動画を選択できます。ユーザーの選択操作の概要をご覧ください。
セッションをポーリングする: アプリは定期的にセッションをポーリングしてステータスを確認する必要があります。mediaItemsSet
プロパティが true を返すことを確認します。これは、ユーザーが選択を完了したことを示します。
選択したメディア アイテムを一覧表示する: mediaItemsSet
が true を返したら、list メソッドを使用して、選択したメディア アイテムの詳細を取得できます。
メディア アイテムを取得して使用: 選択したメディア アイテムにアクセスできるようになりました。baseUrl
を使用してコンテンツを取得し、アプリケーション内で使用できます。
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-11-08 UTC。
[null,null,["最終更新日 2024-11-08 UTC。"],[[["The Picker API lets users securely select photos and videos from their Google Photos library and share them with your application."],["Before using the Picker API, ensure it's the right fit for your use case and properly configure your app with the necessary API and authentication setup."],["The Picker API flow involves creating a session, directing users to the Google Photos app for selection, polling the session for completion, and then retrieving the selected media items."],["Developers should check the provided resources like reference documentation and samples for detailed information and implementation examples."]]],["The Picker API enables users to share media from Google Photos with your app. First, check for and obtain an OAuth token. Then, create a new session via the Picker API, generating a `pickerUri`. Direct users to this URI to select media. Periodically poll the session until `mediaItemsSet` is true. Use the list method to retrieve details of selected items, and then access their content using `baseUrl` for use in your application.\n"]]