I use this code snippet to geocode an address using the Google Geolocation API:
<?php
$address = "Frazione Levà - 16030 Sori (GE)";
$url = 'http://maps.google.com/maps/api/geocode/xml?address='.urlencode($address).'&sensor=false';
echo $url."\n";
$xml = file_get_contents($url);
var_dump($xml);
?>
The echo command shows the url:
http://maps.google.com/maps/api/geocode/xml?address=Frazione+Lev%C3%A0+-+16030+Sori+%28GE%29&sensor=false
and the var_dump command shows the result:
string(107) "<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
<status>ZERO_RESULTS</status>
</GeocodeResponse>
"
Thus, the address cannot be geolocated.
If I named the same URL above ( http://maps.google.com/maps/api/geocode/xml?address=Frazione+Lev%C3%A0+-+16030+Sori+%28GE%29&sensor=false ) from my browser, I get a completely different result (the address is correctly geo-referenced):
<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
<status>OK</status>
...
How is this possible and how can I fix it? I need to bind addresses from PHP.
, , , ; .