Google Geocoding service returns Error 400 Bad Request

别说谁变了你拦得住时间么 提交于 2019-12-05 00:44:50
Chuy

Well, I figured it out.

My $cityName variable was this:

$cityName = "Monterrey, NL";

The white space between the comma and "NL". I used str_replace to change " " for "+" and get a valid url like in the documentation:

http://code.google.com/intl/es/apis/maps/documentation/geocoding/

Greetings and thanks a lot for your help!

I think you're missing the API-Key

Btw, I simply use file_get_contents() for Google's geocoder, since there are no special headers you have to set, or http-redirects you have to follow, etc.

FYI, I just ran into this and my issue was that I had incorrectly typed the "address" query string parameter (I typed it as "adress" rather than "address").

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!