I am trying to use a PHP script to get the Lat/Long of an address using the Google Maps API v3. I have looked at many examples of how to do this, but none of them are working for me. I always get an error in my response. Here is my code:
<?php
$jsonurl = "http://maps.google.com/maps/api/geocode/json?sensor=false&key=MY_API_KEY&address=1600+Pennsylvania+Avenue+Northwest+Washington+DC+20500";
echo $json = file_get_contents($jsonurl);
?>
And here is the output from that script:
{ “results” : [], “status” : “REQUEST_DENIED” }
I have tried everything I can think of to get this working. I have tried generating a new API key with my server IP address to no avail. Has anyone encountered this problem before?
Are you trying to use the web service or the v3 API geocoder?
From php you should use the web service. The documented URL is not the one I see in your post (http://maps.google.com/maps/api/geocode/json), it is http://maps.googleapis.com/maps/api/geocode/json.