1
votes

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:

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.

1
urlencode() on the cityDaniel W.
thanks @geocodezip. I have found the solution on that link. Thanks a lot. I must to encode before in utf-8, then i can use the urlencode.echo89

1 Answers

0
votes

Have you tried rawurlencode?

file_get_contents( rawurlencode( $url ) );