fork download
  1. <?php
  2.  
  3.  
  4. function reverseGeocode($lat, $long) {
  5. $curl = curl_init();
  6.  
  7. CURLOPT_URL => 'https://a...content-available-to-author-only...v.fr/reverse?lat=48.862725&lon=2.287592',
  8. CURLOPT_RETURNTRANSFER => true,
  9. CURLOPT_ENCODING => '',
  10. CURLOPT_MAXREDIRS => 10,
  11. CURLOPT_TIMEOUT => 0,
  12. CURLOPT_FOLLOWLOCATION => true,
  13. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  14. CURLOPT_CUSTOMREQUEST => 'GET',
  15. CURLOPT_HTTPHEADER => array(
  16. 'Cookie: session=VGGDYCXkIaQLFe2-452MvQ|1749427779|K4Dci-XsVuOOiyHmd9pLvg|mM-j-X3LAGEbpliZTpOSwg1lydY'
  17. ),
  18. ));
  19.  
  20. $response = curl_exec($curl);
  21. var_dump($response);
  22. curl_close($curl);
  23. if ($response === false) {
  24. return null; // Handle error
  25. }
  26. $responseData = json_decode($response, true);
  27. var_dump($reponseData);
  28. if (isset($responseData['features']) && count($responseData['features']) > 0) {
  29. $properties = $responseData['features'][0]['properties'];
  30. return array(
  31. 'city' => isset($properties['city']) ? $properties['city'] : '',
  32. 'state' => isset($properties['state']) ? $properties['state'] : '',
  33. 'country' => isset($properties['country']) ? $properties['country'] : ''
  34. );
  35. }
  36. return null; // Handle case where no features are found
  37.  
  38. }
  39.  
  40. $t = reverseGeocode('48.862725','2.287592');
  41.  
  42. echo $t;
Success #stdin #stdout 0.03s 25692KB
stdin
Standard input is empty
stdout
bool(false)