GetReader
GetReader
により、ニュース メディアは、既知の PPID を持つ読者が定期購入を Google にリンクしているかどうか確認できます。ニュース メディアは GET
リクエストを使用して、特定のパブリケーション ID に属する PPID をクエリします。
リクエスト
REST API: GET
リクエスト
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid
クライアント ライブラリ(Node.js)
async function getReader(ppid) {
const publicationId = process.env.PUBLICATION_ID;
return await client.publications.readers.get({
name: `publications/${publicationId}/readers/${ppid}`,
});
};
レスポンス
エンドポイントは、リンクされた定期購入の created_time
を含む JSON 本文とともに 200 を返します。また、パブリケーションに PPID が見つからない場合はエラーを返します。詳しくは、エラーのセクションをご覧ください。
{
"name": "publications/CAowqfCKCw/readers/22553",
"createTime": "2025-07-30T18:26:58.050224Z",
"publicationId": "CAowqfCKCw",
"ppid": "22553",
"originatingPublicationId": "CAowqfCKCw"
}
GetReaderEntitlements
ニュース メディアは GetReaderEntitlements
により、以前に提供した PPID の利用資格をクエリできます。ニュース メディアは GET リクエストを使用して、PPID とパブリケーション ID を指定し、利用資格をリクエストします。
リクエスト
REST API: GET
リクエスト
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid/entitlements
クライアント ライブラリ(Node.js)
async function getReaderEntitlements(ppid) {
const publicationId = process.env.PUBLICATION_ID;
return await client.publications.readers.getEntitlements({
name: `publications/${publicationId}/readers/${ppid}/entitlements`
});
};
レスポンス
リクエストが成功した場合、返される形式は、UpdateReaderEntitlements
PATCH
リクエストの利用資格の保存に使用される形式と同じものです。
{
"name": "publications/dailybugle.com/readers/6789/entitlements",
"entitlements": [
{
"product_id": "dailybugle.com:basic",
"subscription_token": "dnabhdufbwinkjanvejskenfw",
"detail": "This is our basic plan",
"expire_time": "2022-08-19T04:53:40+00:00"
},
{
"product_id": "dailybugle.com:premium",
"subscription_token": "wfwhddgdgnkhngfw",
"detail": "This is our premium plan",
"expire_time": "2022-07-19T04:53:40+00:00"
},
{
"product_id": "dailybugle.com:deluxe",
"subscription_token": "fefcbwinkjanvejfefw",
"detail": "This is our deluxe plan",
"expire_time": "2022-08-20T04:53:40+00:00"
}
]
}
利用資格を持たない(利用資格が期限切れで削除されているなど)が、リンクされた PPID を持つユーザーの場合、利用資格のリクエストは、標準的な Entitlements オブジェクトの一部として空の Entitlements 配列を返します。
{
"name": "publications/dailybugle.com/readers/6789/entitlements"
}
UpdateReaderEntitlements
UpdateReaderEntitlements
は、PPID に基づいて読者の利用資格を作成、更新するために使用されます。
このサンプル ペイロードは、The Daily Bugle の 3 つのプロダクト ID(dailybugle.com:basic
、dailybugle.com:premium
、dailybugle.com:deluxe
)について、読者に PPID 6789
の利用資格を付与します。その後、読者 6789
が、Google 検索や Discover の Google サーフェスを使用すると、いずれかのプロダクト ID でタグ付けされた dailybugle.com の記事から、関連する検索結果が [定期購入の検索結果] リストに表示されます。
リクエスト
REST API: PATCH
リクエスト
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid/entitlements
リクエスト本文: entitlements
オブジェクトの詳細については、用語集のページをご覧ください。
{
entitlements : [{
product_id: `${publicationId}:basic`,
subscription_token: 'abc1234',
detail: 'This is our basic plan',
expire_time: '2025-10-21T03:05:08.200564Z'
}]
}
クライアント ライブラリ(Node.js)
async function updateReaderEntitlements(ppid) {
const publicationId = process.env.PUBLICATION_ID;
const requestBody = {
entitlements : [{
product_id: `${publicationId}:basic`,
subscription_token: 'abc1234',
detail: 'This is our basic plan',
expire_time: '2025-10-21T03:05:08.200564Z'
}]
};
return await client.publications.readers.updateEntitlements({
name: `publications/${publicationId}/readers/${ppid}/entitlements`,
requestBody
});
};
レスポンス
PATCH オペレーションが成功すると、保存された entitlements
オブジェクトが GetReaderEntitlements
と同じ形式で返されます。
DeleteReader
DeleteReader
により、ニュース メディアはリンクされた定期購入を手動で削除できます。ニュース メディアは、DELETE
リクエストを使用して、削除するパブリケーション ID の PPID を送信します。
DeleteReader
を呼び出す前に、まず UpdateReaderEntitlements
を使用して空の配列({ "entitlements": [] }
)で利用資格を削除するか、利用資格を持つ読者を削除する必要がある場合は、オプションの force
パラメータを true
に設定する必要があります。force
パラメータのデフォルトは false
です。
リクエスト
REST API: DELETE
リクエスト
https://readerrevenuesubscriptionlinking.googleapis.com/v1/publications/publicationId/readers/ppid?force={boolean}
クライアント ライブラリ(Node.js)
async function deleteReader(ppid, forceDelete = false) {
const publicationId = process.env.PUBLICATION_ID;
return await client.publications.readers.delete({
name: `publications/${publicationId}/readers/${ppid}`
force: forceDelete
});
};
レスポンス
正常に削除されると、空の JSON オブジェクト {}
とともに 200 が返されます。
{}