【问题标题】:Google API - get locations with Google_Service_MyBusinessBusinessInformationGoogle API - 使用 Google_Service_MyBusinessBusinessInformation 获取位置
【发布时间】:2021-12-07 07:01:57
【问题描述】:

禁用旧的 my_business api (v4),我无法获取位置。我正在使用:

$my_business_account = new Google_Service_MyBusinessAccountManagement($client);
$list_accounts_response = $my_business_account->accounts->listAccounts();
$account = $list_accounts_response[0];
$mybusinessService = new Google_Service_MyBusinessBusinessInformation($client);
$locations = $mybusinessService->accounts_locations;
$queryParams = [
    "pageSize" => 10,
    'readMask' => "user.display_name,photo"
];
$locationsList = $locations->listAccountsLocations($account->name, $queryParams);

我仍然收到 400 响应:

    Google\Service\Exception #400
{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "read_mask",
            "description": "Invalid field mask provided"
          }
        ]
      }
    ]
  }
}

在 API 文档中https://developers.google.com/my-business/reference/businessinformation/rest/v1/accounts.locations/list

readMask 字段是强制性的,但不幸的是,我不知道 PHP API 客户端或 REST(例如 POSTMAN)的写入格式。 有人会帮忙吗?

【问题讨论】:

    标签: php google-api-php-client


    【解决方案1】:

    我的错,使用 readMask 字段必须来自位置属性 (https://developers.google.com/my-business/reference/businessinformation/rest/v1/locations),例如。名称、网站Uri 等 也许它可以帮助某人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-01
      • 2016-05-21
      • 1970-01-01
      • 2016-04-18
      • 1970-01-01
      • 2015-11-03
      • 1970-01-01
      • 2012-05-04
      相关资源
      最近更新 更多