I have a little problem,
I need to get the coordinates of the place from the name of the road (which I provide), I try to do this with file_get_contentsand json_decode, but some of them do not work (return stdClass with ZERO_RESULTS )!
if I copy the url insert (exaccty is the same) in the browser, it will send me the necessary data, does not know why.
if I try with a different road name, it works.
obviously, I already tried to clear the cache, but no result, changing the navigator also does not work, they also tried on several servers, but still no results, tried to do this using CURL ( as indicated in the answer in the message related to the same problem ) but still no result.
I'm completely lost, I hope you can help me.
here is the code.
The data shown refers to the names of the roads in France , you can add "France" to $ a if you want to see it
DATA
$a = "17 bis Les Chaises";
$b = "77510";
$a = "2 rue Jean Moulin";
$b = "70300";
Generated links
https:
https:
Curl
$url = "https://maps.google.com/maps/api/geocode/json?address=".str_replace(" ","+",$a)."+".$b;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
print_r($response_a);
file_get_contents
$j = json_decode(file_get_contents("https://maps.google.com/maps/api/geocode/json?address=".str_replace(" ","+",$a)."+".$b),true);
print_r("https://maps.google.com/maps/api/geocode/json?address=".str_replace(" ","+",$a)."+".$b);echo "\n\n\n\n\n\n\n";
print_r($j["results"][0]["geometry"]["location"]["lat"].",".$j["results"][0]["geometry"]["location"]["lng"]);
var_dump(file_get_contents("https://maps.google.com/maps/api/geocode/json?address=".str_replace(" ","+",$a)."+".$b));
Thanks for reading.