-1

A php client call to geocode api returns nothing (tried with file_get_contents()) while the same in a url from browser call returns results. For instance a call from .php client (using file_get_contents()) to geocode API as

https://maps.googleapis.com/maps/api/geocode/json?address=306+Pineland+place%2CCalgary%2CAB%2CT1Y+3C5%2CCanada&key=__MYAPIkey__

returns nothing, while the same cut and pasted in a browser to call returns results as expected.

Is it apparently a bug in the API?

Tried with urlencode + file_get_contents in php. The var_dump of the results just shows a NULL :(

It should return an array of results with location/logitude/latitude, etc.

Su Atm
  • 17
  • 2
  • 1
    Is there any error you have encountered? Did you have some kind of restriction set on your console? – Yrll Nov 22 '22 at 02:51

1 Answers1

-1

No, it did not return any value, the file_get_contents() is just null.

After a friends's suggestion, modified the code to use curl() replacing the file_get_contents() with exactly the same url to call the api, it works perfectly alright. Looks like the values returned by the google maps api is not compatible to file_get_contents()? No idea!

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 25 '22 at 12:10