Oh noes! Itz Kitchen Duty time!
admin | April 22, 2011

Every day is potentially a coding day! ..But today there was a South Park marathon on tv, so some sofa coding in da kitchenz was a must.
Perfect occasion to start checking out the Halo Reach API, which allows developers to retrieve information about games and players from the Halo universe.
So yea, just for knowledge sharing sake, here a couple of links that supported me in the creation of that small dynamic banner in the sidebar, which automatically loads my current armor and rank using the Bungie.NET API.
First of all, HaloReachAPI.net has a great crash course, which will get you up and running in no time. It also contains what seemed to me to be the most detailed documentation out there.
In order to access the API you will need a valid API key. This key is unique, and can be easily obtained by any Bungie Pro subscriber registered on the Bungie.net forum. You can then use the key to make calls to the API, and juggling with the available methods you will eventually find out a way to obtain the info you were looking for.
In my case I needed the following two things:
Allright, here how to obtain that info in PHP! First of all you’l need to make a call to the API:
$apiKey = ‘ultraSecretAPIKey‘;
$playerGamertag = ‘an evil morlok‘;
$url = ‘http://www.bungie.net/api/reach/reachapijson.svc/player/details/nostats/‘ . rawurlencode($apiKey) . ‘/’ . rawurlencode($playerGamertag);
Remember to substitute apiKey with your actual (secret) API key, and playerGamertag with the player whose info you’re trying to retrieve. According to the method that you are trying to call, the url will look slightly different. In this case I’m executing the GetPlayerDetailsWithNoStats method, which requires such a structure.
$output = file_get_contents($url);
$obj = json_decode($output);
if(!is_object($obj)) die(”Error parsing JSON response\n”);
if(!$obj->Player) die(”Player not found…”);
Here we execute the query to the API, convert it into a PHP object and validate it. If everything succeeds obj will contain whatever the method we called returned us.
And there you have it! You can finally very easily interact with the obj object and retrieve all the fields contained in it. In our case:
..Enjoy!
3dsm adidas advergame campaign advergame advertising age distribution Alternate Reality Game ARG bababa demographics fail game game engine game platform gaming trends graphics greenpeace guerrilla marketing halo halo reach kitchen of wonders Lucas nestle oilspill overfisher planning portfolio preview problem statement prototype quote reach religion resource seashepherd sea shepherd second sprint steve irwin surveys unity unity3d video viral webdesign westra wtf
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.