問題描述
現在大多數瀏覽器都內置了對 Google Geolocation API 的支持.他們通過向 Google 發送附近 802.11 接入點(其信標被您的計算機捕獲的那些)的 MAC 地址來做到這一點.
Support for the Google Geolocation API is now built in to most browsers. They do this, in part, by sending to Google the MAC address of nearby 802.11 access points (those whose beacons are captured by your computer.)
我有大量從不同位置捕獲的 802.11 數據包.我正在尋找 802.11 接入點的地理定位.假設我們只有他們的 mac 地址.這應該可以通過使用 Google Geolocation API 來實現.
I have a large number of 802.11 packets captured from various locations. I'm looking to geolocate the 802.11 access points. Assume that we only have their mac addresses. This should be possible by using the Google Geolocation API.
迄今為止我發現可能對此有所幫助的來源包括:
Sources that I've found to date that might be helpful on this include:
- 來自 Mozilla 1.9.1 代碼庫的地理定位源代碼
- 關于監控 WiFi 接入點的 MDN 文章
- MDN 關于使用地理位置的文章
- Mozilla WebDev 關于在瀏覽器中使用地理定位的文章
第一個可能是最好的選擇.問題是,我不確定如何使用那里的示例并實際創建一個程序,讓我通過管道輸入 MAC 地址并輸出緯度/經度對.我也不確定如何從 Unix/MacOS 命令行運行 JavaScript.
The first is probably the best bet. Problem is, I'm not sure how to use the example there and actually create a program that lets me pipe in the MAC addresses and output lat/long pairs. I'm also not sure how to run JavaScript from a Unix/MacOS command line.
我知道這有很多問題要問,但是有人知道我應該從哪里開始嗎?
I know that this is a lot to ask, but does anybody have any clue where I should start?
推薦答案
<?php
$mac = $_SERVER['argv'][1];
$postData = '{
"version": "1.1.0",
"wifi_towers": [{
"mac_address": "' . $mac . '",
"ssid": "0",
"signal_strength":-72
}]
}';
$opts = array(
'http'=>array(
'method' => "POST",
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postData
)
);
$response = file_get_contents(
'http://www.google.com/loc/json',
false,
stream_context_create($opts)
);
$loc = json_decode($response, true);
echo $loc['location']['latitude'];
echo ',';
echo $loc['location']['longitude'];
命令行用法:
php geo.php "mac addy here"
這篇關于使用 Google Geolocation API 通過 MAC 地址對 802.11 接入點進行地理定位的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!