Exceeded usage limits for Geocoding API

怎甘沉沦 提交于 2019-12-04 03:03:26

Thanks to luke_mclachlan for the fix.

The URL was missing the parameter for the API key e.g.

https://maps.googleapis.com/maps/api/geocode/json?key=AbCdEfGhIjKlMnOpQrStUvWxYz&address=Dallas&sensor=true

What was throwing us was that without the API key there seems to be a lower limit that we were hitting by about 2:30am which didn't appear in testing.

The API key used can be found in the Google Developers Console here: https://console.developers.google.com/project

Click your project name Then look on the left hand menu and click "Credentials" under "APIs & auth" The value "API KEY" is the same for all usages

Jon

priya

Parameter Key was missing.

https://maps.googleapis.com/maps/api/geocode/json?key=AbCdEfGhIjKlMnOpQrStUvWxYz&address=Dallas&sensor=true

key=AbCdEfGhIjKlMnOpQrStUvWxYz needs to be added .

Not sure this is just related to the key query param missing. I see the same misleading API response when the &language=GB&region=UK was replaced by my app to instead query &language=GB®ion=uk. This is server based querying and the API access is authorised by API credentials stored with Google. The API returns:

"You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console"

Response seems to be the generic repsonse for a malformed query string than anything else, key parameter or otherwise.

Valid: https://maps.googleapis.com/maps/api/geocode/json?address=St%20Georges%20Avenue%20Sheerness%20ME12%201QU%20United%20Kingdom&language=GB&region=uk

Invalid: https://maps.googleapis.com/maps/api/geocode/json?address=St%20Georges%20Avenue%20Sheerness%20ME12%201QU%20United%20Kingdom&language=GBfoobar=uk

In my case, I was passing '#' char in ?address=#202, Hollywood park. i removed # from the address api. May be google's api is breaking on spacial character especially #

Shiv Ram
ini_set('allow_url_fopen', 'on');
//ini_set('allow_url_fopen', '1');
$address=urlencode($address);


$address = str_replace(" ", "+", $address);
$json = file_get_contents("https://maps.google.com/maps/api/geocode/json?key=AIzaSyDq-gfJDoytQE6gj0iHXEy4IZQhgLS70-8&address=$address&sensor=true");
$json = json_decode($json);

$lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
$lng = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!