I.T.S. Documentation
In this section we will show how to retrieve the location of a station using the REST API provided by Navizon ITS. Before you begin, you should have already installed and configured your site as described in the documentation.
To run the examples you will need to know the ID of your site and the MAC address of the WiFi station you are querying. This two piece of information are used to create the URL for the request as in the following example:
NOTE: The JSON representation will contain the latest position computed for the device. If the station has
been previously saved in the list of known devices, the returned object will also contain a name and
description fields.
If the device was not active in the site for the past two hours and it is not in the list of known devices, the
server will return a HTTP 404 - Not Found error.
The easiest way to access the Navizon ITS API is using the command line tool curl freely available at
http://curl.haxx.se/. Don't forget to replace username:password with your email address and password (e.g. me@example.com:password123) and
use a proper site ID and MAC address.
curl -u username:password http://its.navizon.com/api/v1/sites/0000/stations/00:00:00:00:00:00/
The Restlet framework provides a convenient access the API from Java. Download the Java SE edition archive and extracts the files in a directory of your choice. Locate and add to your CLASSPATH the following JAR files:
org.restlet.jarorg.restlet.ext.json.jarorg.json.jarThe C# example uses JSON.NET to parse the response. The library is available at json.codeplex.com.
This example uses the JSON library for Ruby available as a gem:
gem install json
The source code for the Base 64 library is available at http://www.webtoolkit.info/javascript-base64.html.
To run this example, save the code in a file named Base64.js located in the same directory as the HTML file.
<!DOCTYPE html>
<html>
<head>
<title>Navizon I.T.S. Javascript Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="Base64.js"></script>
</head>
<body>
<h1>Navizon ITS Javascript Example</h1>
<div id="results"></div>
<script type="text/javascript">
$(document).ready(function() {
var BASE_URL = "http://its.navizon.com/api/v1/",
SITE_ID = "0000", // Your site ID here
STATION_MAC = "00:00:00:00:00:00", // The station's MAC address
USERNAME = "username", // Your username
PASSWORD = "password"; // Your password
// Send the request
jQuery.support.cors = true; // enable cross-site scripting
$.ajax({
type: "GET",
url: BASE_URL + "sites/" + SITE_ID + "/stations/" + STATION_MAC + "/",
beforeSend: function(jqXHR) {
jqXHR.setRequestHeader("Authorization", "Basic " + Base64.encode(USERNAME + ":" + PASSWORD));
},
success: function(station) {
// Output the results
if (typeof station === "string") {
station = JSON.parse(station);
}
$("#results").html(
"Station: " + station.mac + "<br />" +
"loc.lat: " + station.loc.lat + "<br />" +
"loc.lng: " + station.loc.lng + "<br />"
);
},
error: function(jqXHR, textStatus, errorThrown) {
alert('Error');
}
});
});
</script>
</body>
</html>
For debugging and testing, you can also retrieve the location of a device using a browser. We recommend installing a plugin such as JSONView and JSONLint for Google Chrome, or JSONovich for Firefox. After you have installed the plugin, simply type the URL that correspond to your station and supply your credentials when prompted.