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.)
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:
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?
The Geolocation API is a very simple API that allows to get a device's current location coordinates. It has only two methods: getCurrentPosition and watchPosition and the data returned is very straightforward, but when coupled with a mapping API, complex location-aware web apps can be created.
The Geolocation API uses a pay-as-you-go pricing model.
To get current location using HTML5 Geolocation with Google Maps, you need to set an API key for Google Static Maps API. Go to https://console.developers.google.com and get a free API key for Google Map. Add this key to the code to work Geolocation with it.
<?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'];
Command line usage:
php geo.php "mac addy here"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With