迁移首页设置

Merchant API 引入了专用的 Homepage 资源。此资源提供了管理首页声明的新方法,其功能超越了传统的 Content API for Shopping。

如需使用网店功能,您需要完成两个步骤:首先验证所有权,然后为您的账号声明网站所有权。如需完成最后一步,请使用 accounts.homepage.claim。

主要区别

与 Content API for Shopping 相比,Merchant API 进行了多项与首页相关的更改:

  • 专用资源:Merchant API 为所有与首页相关的操作提供了一个独特的 Homepage 资源 (accounts.homepage)。(在 Content API for Shopping 中,您使用 accounts.claimwebsite 执行声明操作,首页网址 (website_url) 是 Account 资源的一部分,声明状态 (website_claimed) 是 AccountStatus 资源的一部分。)
  • 精细方法:Merchant API 提供了以下特定方法:
  • 集中式信息:Merchant API Homepage 资源直接包含 uri(首页网址)和 claimed 状态。对 Homepage 资源执行操作的所有方法都会返回此资源,从而提供有关当前状态的即时反馈。在 Content API for Shopping 中,accounts.claimwebsite 不会返回更新后的状态,需要单独调用。
  • 显式声明:在 Content API for Shopping 中,声明通常是通过将 Account.website_url 更新为空字符串来实现的。Merchant API 提供了专用的 homepage.unclaim 方法。
  • 覆盖版权主张:两个 API 均支持在版权主张流程中使用 overwrite 参数,以便在所有权可以验证的情况下从其他账号接管版权主张。

请求

Merchant API 使用不同的 RESTful 端点来管理首页的不同方面。

请求说明 Content API for Shopping Merchant API
获取首页详情 accounts.get(读取 Account.website_url),accountstatuses.get(读取 AccountStatus.website_claimed) GET /accounts/v1/accounts/{account}/homepage
更新首页 URI accounts.update(设置 Account.website_url) PATCH /accounts/v1/accounts/{account}/homepage
声明主页所有权或重新验证主页 POST /content/v2.1/{merchantId}/accounts/{accountId}/claimwebsite(对使用 accounts.update 设置的 Account.website_url 执行了操作) POST /accounts/v1/accounts/{account}/homepage:claim
声明不拥有首页 accounts.update(将 Account.website_url 设置为空字符串) POST /accounts/v1/accounts/{account}/homepage:unclaim

标识符

Merchant API 中的资源标识已简化。

标识符说明 Content API for Shopping Merchant API
用于资源访问的账号标识符 路径中的 merchantId(高级账号)和 accountId(子账号) account(name 字段的一部分,例如 accounts/{account_id}/homepage)
首页资源标识符 不适用(Account 资源隐式包含) name:accounts/{account_id}/homepage(标识 Homepage 子资源)

方法

Content API for Shopping 中的 accounts.claimwebsite 方法专注于声明操作,现在已成为 Merchant API 的 Homepage 资源中更广泛功能集的一部分。

Content API for Shopping 方法 Merchant API 方法 适用范围和备注
accounts.claimwebsite accounts.homepage.claim 直接发起或重新验证网站声明。作用于之前使用 homepage.update 设置的 uri。包含一个 overwrite 参数。返回 Homepage 资源及其当前的 uri 和 claimed 状态。
accounts.get(读取 Account.website_url),accountstatuses.get(读取 AccountStatus.website_claimed) accounts.homepage.getHomepage 新增了专用方法,只需一次调用即可检索当前首页 uri 及其 claimed 状态。
accounts.update(用于设置 Account.website_url) accounts.homepage.updateHomepage 新增了用于设置或更改主页 uri 的专用方法。
accounts.update(将 Account.website_url 设置为空字符串,作为取消认领的权宜解决方法) accounts.homepage.unclaim 新增了专门用于明确取消主页声明的方法。

详细的字段更改

首页信息的结构和访问方式发生了重大变化,现在转向 Merchant API 中的显式 Homepage 资源。

Content API for Shopping Merchant API 说明
merchantId(accounts.claimwebsite 的路径参数) name(Homepage 方法的路径参数,格式:accounts/{account}/homepage) Merchant API 中 name 字符串的 account 部分对应于 Content API for Shopping 中的 accountId。
accountId(accounts.claimwebsite 的路径参数) name(Homepage 方法的路径参数,格式:accounts/{account}/homepage) 所管理首页对应的特定账号的标识符。
overwrite(ContentAccountsClaimwebsiteRequest 正文和 AccountsCustomBatchRequestEntry 中的布尔值) ClaimHomepageRequest.overwrite(homepage.claim 请求正文中的布尔值) 可选。如果为 true,则尝试声明对网站的所有权,如果请求账号可以验证所有权,则可能会移除其他账号的现有所有权声明。
Account.website_url(Account 资源中的字段,使用 accounts.update 设置,使用 accounts.get 读取) Homepage.uri(Homepage 资源中的字段) 商店首页的 URI(网址)。在 Merchant API 中,这是 Homepage 资源中的一个显式字段。它使用 accounts.homepage.updateHomepage 进行设置,并由所有 Homepage 方法返回。
AccountStatus.website_claimed(AccountStatus 资源中的字段,使用 accountstatuses.get 读取) Homepage.claimed(Homepage 资源中的 output_only 布尔值字段) 指明 uri 是否已声明所有权并经过验证。此状态可直接在所有关联的 Merchant API 方法返回的 Homepage 资源中找到。
不适用 UpdateHomepageRequest.update_mask accounts.homepage.updateHomepage 请求正文参数) homepage.update 的可选字段掩码,用于指定要更新 Homepage 资源的哪些字段(例如 uri)。