-1

My live, staging and localhost had a page where it had a map and store finder.

6 months down the line this now does not work and havent touched the code. I have renewed my API key and still no luck. Now i know the API V2 is now not in use and im wondering if i am using the wrong code (confused myself). In my store finder i have this url:

$url = "http://maps.google.co.uk/maps/geo?q=".urlencode($this->input->post('postcode'))."&output=json&key=MYKEY";

Now reading this page ( https://developers.google.com/maps/documentation/geocoding/#JSON ) this has changed but i just cant seem to get a valid url working!

The error i get is: Message: file_get_contents(http://maps.google.co.uk/maps/geo?q=sr3+4as&output=json&key=MYKEY): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden

And when i type the url string into google i get this message:

We're sorry...

... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.

If someone can guide me to if my url string is wrong above OR if this is another issue i would appreciate it.

Thanks!

user2212564
  • 261
  • 1
  • 7
  • 29
  • 1
    *"The Google Geocoding API has the following limits in place: 2,500 requests per day."*. Did you exceed this? *"If you exceed the 24-hour limit or otherwise abuse the service, the Geocoding API may stop working for you temporarily. If you continue to exceed this limit, your access to the Geocoding API may be blocked."*. Google might have blocked access from your server - if you try the same URL from your own browser, does it then work? – h2ooooooo Oct 24 '13 at 11:09
  • I have checked my visits and it's no where near this at all, thats the thing the site is a microsite and hardly any visitors at the moment. :( – user2212564 Oct 24 '13 at 11:15
  • possible duplicate of [HTTP request failed! HTTP/1.0 403 Forbidden](http://stackoverflow.com/questions/19562200/http-request-failed-http-1-0-403-forbidden) – geocodezip Oct 24 '13 at 12:05

1 Answers1

1

According to the upgrade guide this endpoint URL: http://maps.google.co.uk/maps/geo

Is using the v2 geocoding API.

Developers switching from v2 may be using a legacy hostname — either maps.google.com, or maps-api-ssl.google.com if using SSL. You should migrate to the new hostname: maps.googleapis.com.

This URL based on the information in the update guide works for me:

http://maps.googleapis.com/maps/api/geocode/json?address=nebraska&sensor=false

geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • Thanks for your comment, i've read through this update and i it's still throwing errors back, i must be missing something so simple here, above i will provide an edit of what i have updated the URL to. – user2212564 Oct 24 '13 at 13:38
  • From your edit above, how would the key and the .urlencode($this->input->post('postcode')). fit in? I think this is where i am missing something. Sorry to be a pain. – user2212564 Oct 24 '13 at 13:51
  • Read the documentation. There is no key parameter in v3. You would need to url encode the address parameter. – geocodezip Oct 24 '13 at 14:05