Google Maps Geolocation API返回相同的位置

时间:2014-10-09 21:39:27

标签: php geolocation google-api google-geolocation

我放入Google Maps Geolocation API的每个MAC我得到相同的答案,这是我使用的代码:

<?php
    $mac = "12:34:56:78:90:AB"; //the MAC address you are looking for
    $google_api = "AIzaSyAizb.................."; //my API

    $data = array("macAddress"=> $mac);                                                                    
    $data_string = json_encode($data);                                                                                   

    $ch = curl_init('https://www.googleapis.com/geolocation/v1/geolocate?key=' .     $google_api);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                         
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_REFERER, 'http://www.turkel.com/1');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
        'Content-Type: application/json',                                                                                
        'Content-Length: ' . strlen($data_string))                                                                       
    );                                                                                                                   

    $result = curl_exec($ch);

    echo $result;
?>

回报总是:

  

{&#34; location&#34;:{&#34; lat&#34;:38.907230999999996,&#34; lng&#34;:-77.036464},   &#34;准确度&#34;:95000.0}

0 个答案:

没有答案