Google API 尽管启用了计费,但密钥仍达到最大请求限制
Google API Key hits max request limit despite billing enabled
我相信我已尽一切努力正确设置对距离矩阵的访问 API。
首先,我创建了一个项目和一个结算帐户。该计费帐户已在此项目上启用。
接下来,我启用了距离矩阵 API 并创建了一个不受限制的(目前)API 密钥。
这就是我调用 Google 距离矩阵的方式 API:
var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}&destinations={1}&KEY={2}", originAddress, destinationAddress, apiKey);
var request = WebRequest.Create(requestUri);
var response = request.GetResponse();
return XDocument.Load(response.GetResponseStream());
然后解析从此方法返回的 XDocument,并提取我请求计算的距离。
但是,在 2500 次请求之后,我收到了一条 OVER_QUERY_LIMIT
消息:
You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_
我是否忽略了设置 API 密钥或 project/billing 帐户的任何步骤?或者任何人都可以看到我在我的代码中做错了什么吗?
KEY=
需要小写key=
var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}
&destinations={1}&KEY={2}", originAddress, destinationAddress, apiKey);
应该是:
var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}
&destinations={1}&key={2}", originAddress, destinationAddress, apiKey);
我相信我已尽一切努力正确设置对距离矩阵的访问 API。
首先,我创建了一个项目和一个结算帐户。该计费帐户已在此项目上启用。
接下来,我启用了距离矩阵 API 并创建了一个不受限制的(目前)API 密钥。
这就是我调用 Google 距离矩阵的方式 API:
var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}&destinations={1}&KEY={2}", originAddress, destinationAddress, apiKey);
var request = WebRequest.Create(requestUri);
var response = request.GetResponse();
return XDocument.Load(response.GetResponseStream());
然后解析从此方法返回的 XDocument,并提取我请求计算的距离。
但是,在 2500 次请求之后,我收到了一条 OVER_QUERY_LIMIT
消息:
You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_
我是否忽略了设置 API 密钥或 project/billing 帐户的任何步骤?或者任何人都可以看到我在我的代码中做错了什么吗?
KEY=
需要小写key=
var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}
&destinations={1}&KEY={2}", originAddress, destinationAddress, apiKey);
应该是:
var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}
&destinations={1}&key={2}", originAddress, destinationAddress, apiKey);