Playable Locations API 的终点 URL 是什么?

What is the endpoint URL of the Playable Locations API?

我是 Playable Locations API 的新手,正在尝试提出我的第一个请求。基于 the documentation I'm using the endpoint https://playablelocations.googleapis.com/v3:samplePlayableLocations&key=MY_API_KEY 然而它 returns 一个 404 错误

我应该使用另一个 URL 来处理这些请求吗?

编辑: 这似乎与我传递 API 键的方式有关。如果我删除 &key=MY_API_KEY 我就不会再收到 404 错误。相反,它是一个带有消息 请求缺少有效 API 密钥的 403。 我是否使用了错误的参数来传递密钥?

下面是我使用的代码:

$api_key = 'MY_API_KEY';

$request_url = "https://playablelocations.googleapis.com/v3:samplePlayableLocations&key=$api_key";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_exec($ch);
curl_close($ch);

请注意,虽然它已在 public 文档中可用,但目前可玩位置 API 尚未 public 推出 .这可能是您目前无法使用它的原因之一。此外,在您的可玩位置请求中,确保您在 Google 地图项目下使用自己的有效 API 键,并在您的 GCP 控制台中为您启用可玩位置 API以便能够在您的实施中使用它。

如果您尚未在 GCP 控制台中生成有效的 API 密钥并启用可播放位置 API,您可以查看以下指南:

创建一个 API 密钥:https://www.youtube.com/watch?v=2_HZObVbe-g

启用 API:https://www.youtube.com/watch?v=n1UorU1PALk

此外,您似乎在请求中错误地添加了 "key" 参数。而不是做 https://playablelocations.googleapis.com/v3:samplePlayableLocations&key=

应该是https://playablelocations.googleapis.com/v3:samplePlayableLocations?key=

文档中似乎存在错误,值得在 Google Maps' Public Issue Tracker 中提交文档错误。

此外,您需要有可玩位置的请求正文API,如下所示:

{
  "areaFilter": {
    "s2CellId": string,
  },
  "criteria": [
    {
      "gameObjectType": number,
      "filter": {
          "maxLocationCount": number,
          "spacing": {
            "minSpacingMeters": number,
            "pointType": enum(PointType)
          },
          "includedTypes": [
            string
          ],
      },
      "fieldsToReturn": string
    }
  ]
}

这里有更多信息:https://developers.google.com/maps/documentation/gaming/using_playable_locations