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}`,
});
};
响应
如果未找到相应发布内容的 PPID,该端点将返回 200 和包含关联订阅的 created_time
的 JSON 正文,否则会返回错误。如需了解详情,请参阅“错误”部分。
{
"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 的用户(例如,已过期且已被清除的使用权),使用权请求将在标准使用权对象中返回一个空的使用权数组。
{
"name": "publications/dailybugle.com/readers/6789/entitlements"
}
UpdateReaderEntitlements
UpdateReaderEntitlements
用于根据读者的 PPID 为其创建和更新使用权。
此示例载荷会向读者授予对 The Daily Bugle 的三个商品 ID(dailybugle.com:basic
、dailybugle.com:premium
和 dailybugle.com:deluxe
)的 PPID 6789
使用权。当读者 6789
随后使用 Google 搜索和 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
});
};
响应
成功删除时,系统会返回 200 和空的 JSON 对象 {}
。
{}