使用营业地点数据

本教程介绍了如何创建和修改营业地点数据。借助 My Business Business Information API,您可以执行以下操作:

地理位置可以在 Google Ads 中使用,但必须 已通过验证的资格条件 在 Google 搜索和 Google 地图上展示。位置数据由 accounts.locations

准备工作

在使用 My Business Business Information API 之前,您需要 并获取 OAuth 2.0 凭据。如需详细了解如何开始使用 使用 My Business Business Information API,请参阅基本设置

创建营业地点

您可以使用 My Business Business Information API 为符合以下条件的商家创建新的营业地点: accounts.locations.create

<ph type="x-smartling-placeholder">

如需创建营业地点,请使用以下命令:

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP
POST
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?requestId=requestId&validateOnly=True|False

{
    "storeCode": "GOOG-SYD",
    "languageCode": "en-AU",
    "title": "Google Sydney",
    "phoneNumbers": {
      "primaryPhone": "02 9374 4000"
     }
    "storefrontAddress": {
      "addressLines": [
        "Level 5",
        "48 Pirrama Road"
      ],
      "locality": "Pyrmont",
      "postalCode": "2009",
      "administrativeArea": "NSW",
      "regionCode": "AU"
    },
    "websiteUri": "https://www.google.com.au/",
    "regularHours": {
      "periods": [
        {
          "openDay": "MONDAY",
          "closeDay": "MONDAY",
          "openTime": "09:00",
          "closeTime": "17:00"
        },
        {
          "openDay": "TUESDAY",
          "closeDay": "TUESDAY",
          "openTime": "09:00",
          "closeTime": "17:00"
        },
        {
          "openDay": "WEDNESDAY",
          "closeDay": "WEDNESDAY",
          "openTime": "09:00",
          "closeTime": "17:00"
        },
        {
          "openDay": "THURSDAY",
          "closeDay": "THURSDAY",
          "openTime": "09:00",
          "closeTime": "17:00"
        },
        {
          "openDay": "FRIDAY",
          "closeDay": "FRIDAY",
          "openTime": "09:00",
          "closeTime": "17:00"
        }
      ]
    },
    "categories": {
      "primaryCategory": {
        "name": "gcid:software_company"
      }
     }
}

删除营业地点

您可以使用 My Business Business Information API 删除包含 locations.delete.

如需删除营业地点,请使用以下命令:

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP
DELETE
https://mybusinessbusinessinformation.googleapis.com/v1/locations/{locationId}

按名称获取营业地点

如果您的账号有多个关联的商家,您可能希望 单个营业地点。您可以按商家的以获取特定的 位置 locations.get.

如需按名称获取营业地点,请使用以下命令。您必须指定 readMask 才能检索特定字段。:

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP
GET
https://mybusinessbusinessinformation.googleapis.com/v1/locations/{locationId}?readMask={commaSeparatedFieldsToRetrieve}

返回 Google 地图版本

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP

要返回某个位置的 Google 地图版本,请将 googleUpdated 附加到请求网址,如以下示例所示:

GET
https://mybusinessbusinessinformation.googleapis.com/v1/locations/{locationId}:googleUpdated?readMask={commaSeparatedFieldsToRetrieve}

如果没有结果,则会显示 404 NOT FOUND HTTP 状态代码 返回。如需详细了解如何管理 Google 更新,请点击此处

列出位置

当您管理一个或多个营业地点时,不妨 与您的账号相关联的所有营业地点。使用 accounts.locations.list 列出与某个用户关联的所有营业地点的 API。

要列出已通过身份验证的用户直接拥有或管理的所有营业地点,请使用 以下:

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP
GET
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}

在请求网址中为账号使用 '-' 通配符,以包括 间接拥有的商家信息(通过群组拥有或管理):

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP
GET
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/-/locations?readMask={commaSeparatedFieldsToRetrieve}

过滤列出营业地点时的结果

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP

您可以使用过滤条件来限制调用 accounts.locations.list. 要过滤请求,请将过滤器表达式附加到基准网址,如下所示: 示例:

GET
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter={FIELD_NAME}=%22{YOUR_QUERY}%22

基本查询语法

限制的语法如下: <field><operator><value>, 其中运算符是 EQUALS (=) 或 HAS (:)。EQUALS (=) 和 HAS (:) 运算符等效于除 locationName 之外的所有字段(请参阅 下表)。

引号编码为“%22”使用空格代替加号 (+)。

除非另有说明,否则所有比较都是不区分大小写的令牌 比较。例如:“4 辆车”将与“4, Privet Drive”匹配。

合并一个过滤查询中的多个字段

该 API 允许用 AND 连接所有字段限制。不过, 对 OR 关键字而言,所有限制都必须应用于同一关键字 字段。例如:locationName=A OR labels=B 不是 允许。

示例

以下示例展示了一个过滤条件表达式,该表达式会返回包含以下内容的所有营业地点: “Pepé Le Pew”这个名字其中显示了“french_restaurant”或 “european_餐馆”;以及“新开业”标签

locationName=%22Pepé+Le+Pew%22+AND+
(categories=%22french_restaurant%22+OR+
categories=%22european_restaurant%22)+AND+
labels=%22newly+open%22

按距离或账号搜索

以下示例展示了如何搜索特定区域内的 与某个地理点的距离:

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP
GET
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=distance(latlng, geopoint({latitude}, {longitude}))<{distance}

要过滤美国科罗拉多州博尔德 1000 英里内的位置,请执行以下操作:

GET
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=distance(latlng, geopoint(40.01, -105.27))<1000.0

所有受支持的过滤条件字段列表

下面列出了所有可用于 过滤:

字段 说明和示例
字符串匹配字段
title

商家真实姓名

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=title:"Bajis" (匹配任何包含子字符串“Bajis”的营业地点名称)

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=title="Bajis" (匹配任何以“Bajis”作为令牌/字词的营业地点名称)

categories

主要类别和其他类别的组合。 请注意,“gcid:”必须省略此参数。如果有多个 类别,如果至少有一个类别与此过滤器匹配,则此过滤器匹配 模式。

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=categories="french_restaurant"

phone_numbers.primary_phone

采用 E.164 格式的主要电话号码(例如“+441234567890”)。

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=phone_numbers.primary_phone="+441234567890"

storefront_address.region_code

地址所在国家/地区的 CLDR 地区代码

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=storefront_address.region_code="US"

storefront_address.administrative_area

国家/地区邮政地址中使用的最高行政区划

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=storefront_address.administrative_area="CA"

storefront_address.locality

地址的城市/城镇部分

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=storefront_address.locality="New York"

storefront_address.postal_code

地址的邮政编码

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=storefront_address.postal_code="12345"

metadata.place_id

如果此营业地点已通过验证并已关联到/显示在 Google 地图上,则此字段等于该营业地点的地点 ID

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=metadata.place_id="12345"

openInfo.status

指明营业地点目前是否正常营业 (OPENCLOSED_PERMANENTLY

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=openInfo.status="OPEN"

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=openInfo.status="CLOSED_PERMANENTLY"

labels

一组自由形式的字符串,可让您为自己的商家添加代码。在 与所有其他字段不同,该值必须与完整的 标签(包括大小写,而不仅仅是词元)。例如:如果标签为“XX YY”, 则不是“XX”或“xx yy”将变得一致。

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=labels="newly open"

storeCode

此营业地点的外部标识符,它在指定账号中必须是唯一的

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=storeCode="12345"

函数
distance

允许您根据位置与地理位置点之间的距离进行过滤。

https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&filter=distance(latlng, geopoint(1.0, -25.0))<1000.0

按查询字段排序

您可以按商家名称或商店代码对结果进行升序或 按降序排列。在 orderBy 字符串,如以下示例所示:

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP
GET
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/{accountId}/locations?readMask={commaSeparatedFieldsToRetrieve}&orderBy=locationName,storeCode

修补营业地点

使用 My Business Business Information API 更新包含以下内容的营业地点的一个或多个字段: locations.patch

如需更改营业地点的一个或多个字段,请使用以下代码:

<ph type="x-smartling-placeholder">
</ph> <ph type="x-smartling-placeholder">
</ph>
HTTP

使用营业地点字段添加字段和更新后的值,并使用 作为 fieldMask 的值的更新字段列表(以英文逗号分隔)。

PATCH
https://mybusinessbusinessinformation.googleapis.com/v1/locations/{locationId}?languageCode=language&validateOnly=True|False&updateMask=title
{
    "title": "Google Shoes"
}