Airbana API
The Airbana API allows other websites or even desktop widgits to access all the information in the Airbana database. You will need the Airbana.php file to get started
1. Quick Start
2. Getting a List of Sites in the Airbana database
3. Getting information about an individual site
4. Getting Event Dates
5. Getting GPS Information
6. API Reference
Quick Start
The AirBana API is neatly packaged up in a single php file and is designed to be easy to learn. To start with lets instantiate the class and print out the Airbana version of ‘Hello World’:
<?
include('Airbana.php');
$API = new AirbanaAPI();
print($API->Test());
?>
As you will see its quite easy!
Lets take this a step further and get a list of all the ID’s of Skirmish sites available in the DB:
<?
include('Airbana.php');
$API = new AirbanaAPI();
print($API->GetSiteIDsByType(2);
?>
This will return an XML formatted list of all the SiteID’s in the database that are Skirmish Sites, the XML code will look something similar to this:
<Airbana>
<Site>1</Site>
<Site>2</Site>
<Site>3</Site>
<Site>4</Site>
</Airbana>
With this info you can parse the XML and then get all the information about the chosen Site:
<?
include('Airbana.php');
$API = new AirbanaAPI();
print($API->GetIndivSiteBasic(1);
?>
The fields that will be returned are as below:
<Airbana>
<AirbanaSite id="1">
<Latitude>51.3292</Latitude>
<Longitude>-0.87466</Longitude>
<SiteName>Ambush Eversley7</SiteName>
<Website>www.ambushwargames.com</Website>
</AirbanaSite>
</Airbana>
In some cases you don’t want to have to parse the XML and pull out what you require which is why some functions have HTML alternatives:
<?
include('Airbana.php');
$API = new AirbanaAPI();
print($API->GetIndivSiteBasic_HTML(1);
?>
This will return the following code:
<div id="Airbana_Site">
<h3>Example Name</h3>
<span id="Airbana_Site_Address">
Address Line 1<br/>
Address Line 2<br/>
AA1 0ZZ<br/>
</span>
<span id="Airbana_Site_Email">
name@example.com<br/>
</span>
<span id="Airbana_Site_Phone">
01234 567890<br/>
</span>
<span id="Airbana_Site_Features">
UKARA_Image<br/>
UKASGB_Image<br/>
Environment_Image<br/>
OnSiteShop_Image<br/>
Explosives_Image<br/>
BatteryCharge_Image<br/>
Repair_Image<br/>
</span>
</div>
This will allow you to define the AirbanaSite class in your sites CSS and format it as required.
Hopefully this quick start will show you the benefits of the Airbana API, good luck with your experimenting!
Getting a List of Sites in the Airbana database
This was briefly touched on in the Quick Start however there are several functions in the API for getting the list of sites, many of these are designed to allow filtering or attributes so you don’t have to!
Sites in Airbana are designated a ‘Type’ Field to determine what they are. At the moment an entry can be one of the following:
Skirmish 1
Retailer - 2
As covered briefly above this allows you to filter straight away between Airsoft Retailers and Skirmish Sites. To get this information out of Airbana use the following code:
<?
include('Airbana.php');
$API = new AirbanaAPI();
print($API->GetSiteIDsByType(2);
?>
The resulting XML is not very useful but you could then use it to pull information about each site in the DB:
<?
include('Airbana.php');
$API = new AirbanaAPI();
$ReturnedXML = $API->GetSiteIDsByType(2);
$xml = @simplexml_load_string($ReturnedXML);
if ($xml)
{
$XMLArray = XMLToArray($xml);
}
else
{
$array = false;
}
foreach($XMLArray as $AirbanaSite)
{
foreach($AirbanaSite as $Site)
{
print($API->GetIndivSiteBasic($Site['SiteID']));
}
}
function XMLToArray($xml)
{
if (!($xml->children()))
{
return (string) $xml;
}
foreach ($xml->children() as $child)
{
$name=$child->getName();
if (count($xml->$name)==1)
{
$element[$name] = XMLToArray($child);
} else
{
$element[][$name] = XMLToArray($child);
}
}
return $element;
}
?>
Getting information about an individual site
Once you have identified a site that you want to work with in more detail the Airbana API comes into its own. There are several functions that allow you to get additional info about a site:
<?
include('Airbana.php');
$API = new AirbanaAPI();
print($API->GetIndivSiteDetail(1));
print($API->GetWikiEntry(1));
print($API->GetPrices(1));
?>
Getting Event Dates
Its all well and good knowing where sites are but maybe you want to pull the information about when they are! With the Airbana API this is easy. To get all the Events between today and 7 days away simply use this code:
<?
include('Airbana.php');
$API = new AirbanaAPI();
$StartDate = date(”Y-m-d”);
$EndDate = date(”Y-m-d”, mktime(0, 0, 0, date(”m”) , date(”d”)+7, date(”Y”)));
print($API->GetGameDates($StartDate,$EndDate));
?>
Getting GPS Information
All this information is well and good but your Garmin or TomTom device don’t know how to use any of this information so the Airbana API can pump out all the information you need straight to TomTom and Garmin friendly file formats!
<?
include('Airbana.php');
$API = new AirbanaAPI();
print($API->GetGarmin());
?>
or
<?
include('Airbana.php');
$API = new AirbanaAPI();
print($API->GetTomTom());
?>
API Reference
test
Arguments: None | Returns: String, Plain Text
Description:
GetSMSCount
Arguments: None | Returns: String, XML
Description: I can’t even remember why I put this in, simply returns the number of texts requested in the last X minutes.
GetSiteCount
Arguments: None | Returns: String, XML
Description: Returns an int with the total number of sites (Retail and Skirmish) in the Airbana database.
GetGameDateCount
Arguments: None | Returns: String, XML
Description: Returns an int with the total number of Events (for both Retail and Skirmish) in the Airbana database.
GetAllBasic
Arguments: None | Returns: XML DOM
Description: Returns the SiteID, Latitude, Longitude, SiteName and Website URL for every site in the database.
GetSiteIDsByType
Arguments: Type - int | Returns: XML DOM
Description: Returns an XML array of the details in GetAllBasic but filtered by Type (Skirmish vs Retail)
GetIndivSiteBasic
Arguments: SiteID - int | Returns: XML DOM
Description: Returns the same data as GetAllBasic but filtered to an individual site
GetIndivSiteBasic_HTML
Arguments: SiteID - int | Returns: String, HTML Text
Description:
GetIndivSiteDetail
Arguments: SiteID - int | Returns: XML DOM
Description: Returns a higher level of detail about an individual site. SiteID, Latitude, Longitude, Name, Website URL, Phone Number, Email Address, Postal Details, ASCUK URL & Features (UKARA registered, environment type etc)
GetGameDates
Arguments: StartDate - “Y-m-d”, EndDate - “Y-m-d” | Returns: XML DOM
Description: Returns a list of Events within that time period including all neccessary supplemental details (description, date, SiteID etc)
GetWikiEntry
Arguments: SiteID - int | Returns: String, XML
Description: Returns the current wiki entry for this site.
GetPrices
Arguments: SiteID - int | Returns: XML DOM
Description: Returns the prices held in the Airbana Database and gets the remote prices using Airbana’s XMLRPC tech.
GetGarmin
Arguments: None | Returns: String, Plain Text, CSV
Description: Returns a CSV file of all sites in the Database including co-ordinates, Site Name and phone number. Can be used with Garmin and or other CSV importable devices
GetTomTom
Arguments: None | Returns: OV2
Description: Returns an OV2 file that can be imported into TomTom - WARNING EXPERIMENTAL!