views:

422

answers:

3

Hello guys,

I am having a weird problem. Suddenly my PHP implementation of the Google Geocoding API has simply decided to stop working. It now returns error 602 for every request, meaning address unavailable. But, if I open the actual url I am querying, it works perfectly and I can download the correct information. But if I use curl to grab it, 602 is returned instead of 200.

I have tried changing the API key, as well as checking and testing the url.

A: 

It returns 602 if it fails to geocode the address that it is trying.

Martin Murphy
It fails for every address, but every one of the addresses it fails for, if I just browse the url I am grabbing from curl, works fine.
James
Could be a mismatch on your api key possibly. Do you have sensor set to false?
Martin Murphy
+1  A: 

I'm using the following method to geocode. You could try it out just to make sure that it's not a cURL problem.

$request_url = $base_url . "&q=" . urlencode($address);
$xml_string = file_get_contents($request_url);
$xml_string = str_replace('xmlns=', 'ns=', $xml_string);
$xml = simplexml_load_string($xml_string);

Also, if you haven't seen this tutorial on geocoding with PHP, be sure to check it out.

Chris B
Same response as current.
James
A: 

Google now enforces valid key in your request so make sure you specify &key=YOUR_VALID_KEY&sensor=false in your request.

If you don't pass a valid key you'll get 602

hosiawak