I am attempting to set up a script that uses Google’s Geocoding service. However, I have encountered a strange problem when making requests. Here is my simplified request:
<?php
$xml = simplexml_load_file("http://maps.google.com/maps/geo?output=xml&key=MY_API_KEY&q=1600+Pennsylvania+Avenue+Northwest+Washington+DC+20500");
print_r($xml);
?>
Here is the output from that code:
SimpleXMLElement Object ( [Response] => SimpleXMLElement Object ( [Status] => SimpleXMLElement Object ( [code] => 620 [request] => geocode ) ) )
It is returning the error code 620, which means I am making requests too rapidly. However, I am only making a single request and I have not even come close to my request limit. What is even more strange is that when I access the URL directly, it returns the XML response without any trouble at all. It is like there is some kind of firewall/permissions setting somewhere that is blocking the correct response from my PHP script. Any ideas?
Fyi, my final solution was to rewrite the script using Javascript and doing everything client side instead of server side. I’m still not quite sure what was wrong with the request I was making from my php script, but at least I accomplished what I needed. Thanks for all the suggestions!