I have a problem with google maps api using PHP. I use file_get_contents
function to do the get request to google, and its work fine. But I if i do a get request with a city with accented letters, it don't work and return me INVALID_REQUEST
. My example is:
- http://maps.googleapis.com/maps/api/geocode/json?address=Nardò&sensor=false
- http://maps.googleapis.com/maps/api/geocode/json?address=Milano&sensor=false
The first don't work, the second work perfectly with file_get_contents. If i do an encode of the url don't work, using urlencode. Another thing is that if i cut and paste the first url in the browser, it works! So it isn't a problem with google, but i'm wrong something with the encode of the get call from php. Anyone can help me?
Thanks a lot.
urlencode()
on the city – Daniel W.http_build_query()
– Dr.Molle