谷歌地图api尝试使用印地语中的地点ID获取地址

时间:2015-12-03 15:04:24

标签: php google-maps curl

我正试图在印地语中使用place_id获取地址,但我得到了一些特殊字符。请有人帮助我。

<?php 

    $url = 'https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJLbZ-NFv9DDkRzk0gTkm3wlI&language=hi&key=AIzaSyBt7SRPMKW4pWc06NwuzFNCErXxnIlyEIY';



    $headers = array(
        'Content-Type: application/json'
    );
    // OPEN CONNECTION 
    $ch = curl_init();

    // Set the url, number of POST vars, POST data
    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_POST, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Disabling SSL Certificate support temporarly
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    //curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

    // Execute post
    $result = curl_exec($ch);

    if(curl_errno($ch)){
        echo curl_error($ch);
    }

    // Close connection
    curl_close($ch);

    $result=json_decode($result);
    //pr($result);  

    echo "<pre>";print_r($result->result->formatted_address);

?>

0 个答案:

没有答案