google maps - Why do I receive OVER_QUERY_LIMIT answer of my first request? -
i'm using following code coordinates of city, based on request made android app server.:
function getgpslocation($reqlocation) { $url = "http://maps.googleapis.com/maps/api/geocode/json?address=" . $reqlocation . "&sensor=false"; $attempt = 0; $this->log($url, 'debug' ); $location = [ 'lat' => 0.0, 'lng' => 0.0 ]; while ($attempt < 3) { $timeout = 5; $ch = curl_init($url); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout, $timeout); $content = curl_exec($ch); $resulthttpcode = curl_getinfo($ch, curlinfo_http_code); curl_close($ch); if ($resulthttpcode == '200') { $result = json_decode($content); if ($result->status == 'over_query_limit') { $this->log($result->status, 'debug' ); sleep(2); $attempt ++; } else { /* * todo: store result prevent other similar request later. */ if ($result != null) { $location = $result->results[0]->geometry->location; } break; } } } return $location; }
this code works on local server over_query_limit error on request when performed online server.
the google doc (https://developers.google.com/maps/documentation/business/articles/usage_limits), doesn't tell me supposed explain behaviour.
any idea?
use key in request web service, google can keep requests separate others (i assume) shared server.
from documentation
api key
note: maps work users must include client , signature parameters requests instead of key.
all geocoding api applications should use api key. including key in request:
allows monitor application's api usage in google developers console. enables per-key instead of per-ip-address quota limits. ensures google can contact application if necessary. geocoding api uses api key identify application. api keys managed through google apis console. create key:
visit apis console @ google developers console , log in google account. click services link left-hand menu in apis console, activate geocoding api service. once service has been activated, api key available api > access page, in simple api access section. geocoding api applications use key server apps. specify key in request, include value of key parameter.
note: default, key can used server. recommend restrict use of key ip address servers administer. can specify ip addresses allowed use api key clicking edit allowed referers... link in api console.
note: https enforced requests include api key.
Comments
Post a Comment