php - Google Maps Geocode [Invalid_request] but valid URL -



php - Google Maps Geocode [Invalid_request] but valid URL -

i'm using function lat en lng adresses in database:

function geocode($street,$city,$country) { $straat = preg_replace('/ /', '+', $street); $stad = preg_replace('/ /', '+', $city); $land = preg_replace('/ /', '+', $country); $addr = $straat . '+' . $stad . '+' . $land; $apiuri = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . $addr; $geocode=file_get_contents($apiuri); $output= json_decode($geocode); $lat = $output->results[0]->geometry->location->lat; $long = $output->results[0]->geometry->location->lng; $latlng['lat'] = $lat; $latlng['long'] = $long; homecoming $latlng; }

with adresses works perfect, { "results" : [], "status" : "invalid_request" } $apiuri works fine when copy-pasted.

i tried rawurlencode , utf8_encode on $straat, $stad , $land no effect.

working link : https://maps.googleapis.com/maps/api/geocode/json?address=Široká+5+prague+czech+republic (as outputed function above)

the fault encoding of adress, fail see or how.

php google-maps google-geocoder

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -