迁移首页设置

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(子账号) accountname 字段的一部分,例如 accounts/{account_id}/homepage
首页资源标识符 不适用(隐式适用于 Account 资源) nameaccounts/{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 资源及其当前 uriclaimed 状态。
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 说明
merchantIdaccounts.claimwebsite 的路径参数) nameHomepage 方法的路径参数,格式:accounts/{account}/homepage Merchant API 中 name 字符串的 account 部分对应于 Content API for Shopping 中的 accountId
accountIdaccounts.claimwebsite 的路径参数) nameHomepage 方法的路径参数,格式:accounts/{account}/homepage 正在管理首页的特定账号的标识符。
overwriteContentAccountsClaimwebsiteRequest 正文和 AccountsCustomBatchRequestEntry 中的布尔值) ClaimHomepageRequest.overwritehomepage.claim 请求正文中的布尔值) 可选。如果 true,则尝试声明对相应网站的所有权,如果请求账号可以验证所有权,则可能会移除另一账号的现有所有权声明。
Account.website_urlAccount 资源中的字段,使用 accounts.update 设置,使用 accounts.get 读取) Homepage.uriHomepage 资源中的字段) 商店首页的 URI (网址)。在 Merchant API 中,这是 Homepage 资源中的一个显式字段。该值使用 accounts.homepage.updateHomepage 设置,并由所有 Homepage 方法返回。
AccountStatus.website_claimedAccountStatus 资源中的字段,使用 accountstatuses.get 读取) Homepage.claimedHomepage 资源中的 output_only 布尔值字段) 指明 uri 是否已声明并经过验证。此状态直接显示在所有相关联的 Merchant API 方法返回的 Homepage 资源中。
不适用 UpdateHomepageRequest.update_mask accounts.homepage.updateHomepage 请求正文参数) homepage.update 的可选字段掩码,用于指定要返回哪些字段(例如,Homepage 资源的 uri 正在更新。