22 August 2010 ~ Comments Off

phpArmory for WoW

php

phpArmory is a PHP class library. It allows php software developers to easily access data from the World of Warcraft Armory website. This is useful because the Armory website contains up-to-date and official details on characters, guilds, and items in World of Warcraft.

I discovered this simple library about 4 days ago and have been reviewing it. I came to a conclusion to use it after about 3 hours of playing with it! I was able to pull back all the information i needed to complete my new application and add-on to Wordboxes. Below i will cover a few samples of what this class will do.

Character

The first thing i did was try to pul my character information back. This was simple and done quickly with just a few minor calls. Once i got the multi level array back (when i say multi level I am talking about 4 to 5 levels deep) i was able to sift through it by using print_r() and a pre tag.

// First include the phpArmory class
include 'classes/phpArmory.class.php';
$a = new phpArmory();
 
// Character lookup
$character = $a->characterFetch('Name', 'Realm');
 
print_r($character);

Now, I wanted to take this a bit farther and list my characters gear with the image and item level. Below is a foreach loop, looping through the ‘item’ array. You may also notice i am 4 levels deep in the array at this point, i figured that out by just looking at the above code output. As i am looping through the ‘item’ array i will also have to step one level deeper into the ‘attributes’ array so i can see the information on the gear.

foreach($character['characterinfo']['charactertab']['items']['item'] as $item){
	echo '<p><img class="gearicon" src="http://www.wowarmory.com/wow-icons/_images/64x64/'.$item['attributes']['icon'].'.jpg" alt="' . $item['attributes']['name'] . '" />';
	echo $item['attributes']['name'] . ' (ilvl ' . $item['attributes']['level'] . ')</p>';
}

The above will output:

Items

Another great thing about this library is that you are able to pull back just single items based on ID. This is great because after pulling back character info you also get gear ID’s. Then you can use the gear ID’s to get more information on that single item. This also makes it handy for tool tips as you will see on may wow sites.

// Item lookup
$item = $a->itemFetch(41922);
 
print_r($item);

The above will be a large multi level array with that item information.

Other stuff

There are other things you can use this library for such as Guild lookups and PVP team lookups.

Download the phpArmory.class.php and start building a web based wow app! Full documentation and support at http://phparmory.sourceforge.net/.

Tags:

Comments are closed.