1

我放入 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;
?>

回报总是:

{“位置”:{“纬度”:38.907230999999996,“lng”:-77.036464},“准确度”:95000.0}

4

0 回答 0