我相信我已经做了一切正确设置对Distance Matrix API的访问。
首先,我创建了一个项目和一个结算帐户。该计划帐户已在此项目中启用。
接下来,我启用了Distance Matrix API并创建了一个不受限制的(现在)API密钥。
这就是我调用Google Distance Matrix 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密钥或项目/结算帐户的所有步骤?或者任何人都可以在我的代码中看到我做错了什么?
答案 0 :(得分:1)
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);