API 方法

GetReader

借助 GetReader,发布商可以验证其某个具有已知 PPID 的读者是否已将其订阅关联到 Google。发布商使用 GET 请求查询属于特定发布内容 ID 的 PPID。

请求

//GET /v1/publications/dailybugle.com/readers/6789

响应

端点会返回 200(带有包含关联订阅的 created_time 的 JSON 正文),或者如果找不到发布内容的 PPID,则返回错误。如需了解详情,请参阅“错误”部分

{
  "name": "publications/gtech-demo.appspot.com/readers/81112",  
  "create_time": "2022-04-19T04:53:40+00:00"
}

GetReaderEntitlements

借助 GetReaderEntitlements,发布商可以查询发布商之前提供的 PPID 的使用权。使用 GET 请求,发布商可以通过提供 PPID 和发布内容 ID 来请求使用权。

请求

//GET /v1/publications/dailybugle.com/readers/6789/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",
  "createTime": "2023-02-07T17:38:57.425577Z"
}

UpdateReaderEntitlements

UpdateReaderEntitlements 用于根据读者的 PPID 为其创建和更新授权。

此示例载荷会向读者授予 PPID 6789 使用权,以便读者访问 Daily Bugle 的三个产品 ID:dailybugle.com:basicdailybugle.com:premiumdailybugle.com:deluxe。如果读者 6789 随后使用 Google Surfaces for Google 搜索和 Google 探索,“来自您的订阅项目”列表将会显示来自 dailybugle.com 文章的所有相关结果,这些文章带有上述任何产品 ID。

请求

//PATCH /v1/publications/dailybugle.com/readers/6789/entitlements

{
  "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"
      }
  ]
}

响应

PATCH 操作成功后,系统将返回已保存的 entitlements 对象,格式与 GetReaderEntitlements 相同。

DeleteReader

借助 DeleteReader,发布商可以手动删除读者的关联订阅。发布商使用 DELETE 请求提交要删除的发布内容 ID 的 PPID。

请求

//DELETE /v1/publications/dailybugle.com/readers/6789

响应

如果删除成功,则返回 200 及空的 JSON 对象 {}

{}