sql >> Base de Datos >  >> RDS >> Mysql

¿Cómo convertir Lat Long a dirección en php con json api?

Está intentando acceder a la URL, no a un archivo, use CURL en lugar de acceder al archivo directamente.

Reemplazar

        <?php
           $latlong = $row[1].','.$row[2];
           $geocode=json_decode(file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=19.0978,22.8972&sensor=false',true));            
        ?> 

Para

<?php
    $url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=$row[1],$row[2]&sensor=false";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);
    $geocode = json_decode($output);
?>