The official PHP/MySQL Google Maps Geocoding example uses simplexml_load_file that doesn’t handle a proxy so if your script is behind a proxy, you can’t use it.
The problem can be overcome by using stream_context_create and file_get_contents as described in the following snippet:
$request_url = $base_url . "&q=" . urlencode($address);
$params = array (
'http' => array (
'header' => 'Cache-Control: no-store, no-cache, must-revalidate',
'proxy' => 'tcp://proxy.your_domain.com:8080',
'request_fulluri' => true
)
);
$ctx = stream_context_create($params);
$xml = new SimpleXMLElement(file_get_contents($request_url,
false, $ctx));
// $xml->Response->Placemark->Point->coordinates;
Last update: 2009-08-11
