I can not figure out how the Google Maps API works.
I use the address decoder if I enter the following from the browser:

https://maps.googleapis.com/maps/api/geocode/json?address=g.Moscow

All OK: works, shows the coordinates. As soon as I transfer everything to the server, I do not want to work. I have already registered for the domain name key . I enter it.

I get the data like this:

 $url_map_api = "https://maps.googleapis.com/maps/api/geocode/json?address=".$address."&key=KEY_APP"; $content = file_get_contents($url_map_api); 

I used to swear that the key was not the same - now it seems I registered the KEY, but the answer is empty (returns nothing). Who worked? What else needs to be configured?

I have already disabled v3 in the Google Console, enabled only v2 - still nothing (empty answer). : (((

  • one
    There actually "&key=KEY_APP"; Is it written, or did you just write it instead of a real key? - Peter Olson
  • Instead of the real key - inkognitum

1 answer 1

I think that file_get_contents does not accept + https from another domain. You need CURL here!

Https wrapper available for your php scripts.

 $w = stream_get_wrappers(); echo 'openssl: ', extension_loaded ('openssl') ? 'yes':'no', "\n"; echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n"; echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n"; echo 'wrappers: ', var_dump($w); 

the output should be something like

 openssl: yes http wrapper: yes https wrapper: yes wrappers: array(11) { [...] } 
  • Try to write more detailed answers. Explain what is the basis of your statement? - Nicolas Chabanovsky
  • Thanks, it really helped. - inkognitum