How to Use the Airbana API A quick start guide to adding Airsoft Info to your application
Using the Airbana API is simple...
The following Quick Start Guide is based on a PHP without using an API key
Airsoft Data
First you need to decide what data you are going to work with.The Airbana API allows you to retrieve a collection of Sites, details of an individual Site, a collection of Events or an individual Event.
For this example we'll be using a collection of events.
Your Return Type
As mentioned on the front page the API can return data in 3 formats;Serialized PHP:
a:3:{
s:4:"Site";
a:17:
{
s:6:"SiteID"; s:3:"100";
s:8:"SiteName"; s:18:"Airbana Datacenter";
s:7:"Website"; s:17:"www.Airbana.co.uk";
s:12:"ContactPhone"; s:12:"0871 3096879";
s:12:"ContactEmail"; s:20:"gareth@airbana.co.uk";
s:8:"Address1"; s:0:"";
s:8:"Address2"; s:0:"";
s:8:"PostCode"; s:0:"";
s:9:"ForumLink"; s:0:"";
s:4:"Type"; s:1:"1";
s:6:"UKASGB"; s:1:"0";
s:5:"UKARA"; s:1:"0";
s:10:"ShopOnSite"; s:1:"0";
s:17:"ExplosivesAllowed"; s:1:"0";
s:11:"Environment"; s:1:"2";
s:15:"BatteryCharging"; s:1:"0";
s:7:"Repairs";s:1:"0";
}
s:9:"TimeStamp"; i:1266081702;
s:9:"errorcode";i:0;}
s:4:"Site";
a:17:
{
s:6:"SiteID"; s:3:"100";
s:8:"SiteName"; s:18:"Airbana Datacenter";
s:7:"Website"; s:17:"www.Airbana.co.uk";
s:12:"ContactPhone"; s:12:"0871 3096879";
s:12:"ContactEmail"; s:20:"gareth@airbana.co.uk";
s:8:"Address1"; s:0:"";
s:8:"Address2"; s:0:"";
s:8:"PostCode"; s:0:"";
s:9:"ForumLink"; s:0:"";
s:4:"Type"; s:1:"1";
s:6:"UKASGB"; s:1:"0";
s:5:"UKARA"; s:1:"0";
s:10:"ShopOnSite"; s:1:"0";
s:17:"ExplosivesAllowed"; s:1:"0";
s:11:"Environment"; s:1:"2";
s:15:"BatteryCharging"; s:1:"0";
s:7:"Repairs";s:1:"0";
}
s:9:"TimeStamp"; i:1266081702;
s:9:"errorcode";i:0;}
JSON:
{"Site":
{
"SiteID":"100",
"SiteName":"Airbana Datacenter",
"Website":"www.Airbana.co.uk",
"ContactPhone":"0871 3096879",
"ContactEmail":"gareth@airbana.co.uk",
"Address1":"",
"Address2":"",
"PostCode":"",
"ForumLink":"",
"Type":"1",
"UKASGB":"0",
"UKARA":"0",
"ShopOnSite":"0",
"ExplosivesAllowed":"0",
"Environment":"2",
"BatteryCharging":"0",
"Repairs":"0"
},
"TimeStamp":1266082458,
"errorcode":0}
{
"SiteID":"100",
"SiteName":"Airbana Datacenter",
"Website":"www.Airbana.co.uk",
"ContactPhone":"0871 3096879",
"ContactEmail":"gareth@airbana.co.uk",
"Address1":"",
"Address2":"",
"PostCode":"",
"ForumLink":"",
"Type":"1",
"UKASGB":"0",
"UKARA":"0",
"ShopOnSite":"0",
"ExplosivesAllowed":"0",
"Environment":"2",
"BatteryCharging":"0",
"Repairs":"0"
},
"TimeStamp":1266082458,
"errorcode":0}
XML:
<xml version="1.0" encoding='UTF-8'>
<AirbanaAPI>
<SiteID>100</SiteID>
<SiteName>Airbana Datacenter</SiteName>
<Website>www.Airbana.co.uk</Website>
<ContactPhone>0871 3096879</ContactPhone>
<ContactEmail>gareth@airbana.co.uk</ContactEmail>
<Type>1</Type>
<UKASGB>0</UKASGB>
<UKARA>0</UKARA>
<ShopOnSite>0</ShopOnSite>
<ExplosivesAllowed>0</ExplosivesAllowed>
<Environment>2</Environment>
<BatteryCharging>0</BatteryCharging>
<Repairs>0</Repairs>
<timestamp>1266082316</timestamp>
<errorcode>0</errorcode>
</AirbanaAPI>
<AirbanaAPI>
<SiteID>100</SiteID>
<SiteName>Airbana Datacenter</SiteName>
<Website>www.Airbana.co.uk</Website>
<ContactPhone>0871 3096879</ContactPhone>
<ContactEmail>gareth@airbana.co.uk</ContactEmail>
<Type>1</Type>
<UKASGB>0</UKASGB>
<UKARA>0</UKARA>
<ShopOnSite>0</ShopOnSite>
<ExplosivesAllowed>0</ExplosivesAllowed>
<Environment>2</Environment>
<BatteryCharging>0</BatteryCharging>
<Repairs>0</Repairs>
<timestamp>1266082316</timestamp>
<errorcode>0</errorcode>
</AirbanaAPI>
We'll be using PHP which means we need to use a file with .php at the end, in this case;
http://api.airbana.net/2.0/events.php
Processing the Data
By default events.php will return the next 7 days worth of events for the entire world.For our example we are going to limit it to just the UK (Region 1) which means we need to pass the region parameter as follows;
http://api.airbana.net/2.0/events.php?region=1
In PHP we can request this data via CURL, unserialize it and then output it!
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, "http://api.airbana.net/2.0/events.php?region=1");
$result = curl_exec($ch);
$resultArray = curl_getinfo($ch);
$AirbanaAPIReturn = unserialize($result);
if($AirbanaAPIReturn['errorcode'] == '0')
{
foreach($AirbanaAPIReturn['Events'] as $AirsoftEvent)
{
if(is_array($AirsoftEvent))
{
print($AirsoftEvent['EventStartDate'].' - '.$AirsoftEvent['EventName'].'<br/>');
}
}
}
else
{ print("There was a problem retreiving the data");
}
?>
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, "http://api.airbana.net/2.0/events.php?region=1");
$result = curl_exec($ch);
$resultArray = curl_getinfo($ch);
$AirbanaAPIReturn = unserialize($result);
if($AirbanaAPIReturn['errorcode'] == '0')
{
foreach($AirbanaAPIReturn['Events'] as $AirsoftEvent)
{
if(is_array($AirsoftEvent))
{
print($AirsoftEvent['EventStartDate'].' - '.$AirsoftEvent['EventName'].'<br/>');
}
}
}
else
{ print("There was a problem retreiving the data");
}
?>
Done!
Now that you've seen how easy it is to get the Airbana data into your appliactions I would recommend you read more about the parameters for the various parts of the API!Sites Using the API Why not check out their website too..
Blog The latest Airbana news....
- Airbana Android Airsoft App Updated
- Android Airsoft App 1.2 Coming Soon
- Improvements to www.AirsoftMap.net
- New Updates for API, Widgets, Facebook & Calendar
- New Skirmish Sites Added in June 2010
- Airbana At The Airsoft Arms Fair
- Preparing for the Airsoft Arms Fair
- New Version of Airbana Button Released
Contact Details Why not get in touch?
I'm always interested to hear what the Airsoft community thinks of Airbana and what it would like to see Airbana do next.
- Address:
-
www.Airbana.net
www.AirsoftMap.net
- Phone:
- +44 871 3096879
- Twitter:
- @Airbana
- E-mail:
- Gareth@Airbana.net
Airsoft News:
Arnies Airsoft:-
Popular Airsoft:
- Meet the IWI ACE Family
- GFC Custom HK416 NPAS GBB
- Airsoft GI Custom F-Chu Tiger Cat
- TM Biohazard 2 Limited Edition
- eAiming 552 Fully Adjustable Scope
- VFC MK18 Mod1 GBB and More at WGC
Arnies Popular Airsoft