迁移首页设置

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 provides a dedicated 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)。