I got hooked up to this parser stuff (again) and wrote a new parser from scratch in PHP. It highly depends on OOP, the SPL and SimpleXml - so don't try it < PHP 5.2. It's designed to fit in a ZendFramework environment but also runs completely standalone. You are able to plugin various classes for ArmoryResolvers ( currently supported: StreamContext and untested cUrl ), CacheLayers ( Mysqli ), and ArmoryPages ( Character, CharacterAchievements ) or write your own against the provided interfaces. There are also demo clients included which should demonstrate the usage of the parser.
Source for the simple client w/o using cache or errorhandling

#
<?php
//Get all needed includes
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ArmoryStream' . DIRECTORY_SEPARATOR . 'ArmoryStream.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ArmoryStream' . DIRECTORY_SEPARATOR . 'Page' . DIRECTORY_SEPARATOR . 'Achievements.php';
//Setup the StreamObject and tell it to use the european Armory data.
$oClient = new ArmoryStream();
$oClient->setLocation( ArmoryStream::LOCATION_EUROPE );
//Setup the PageObject. Use the Achievement page and get FeastsOfStrength of a character
$oCharacterPage = new ArmoryStream_Page_Achievements();
$oCharacterPage->setCharacter('Nnoitra')
->setRealm("Gul'dan")
->setCategory( ArmoryStream_Page_Achievements::CATEGORY_FEASTSOFSTRENGTH );
//Stream data from Armory into the PageObject
$oClient->streamIntoPage( $oCharacterPage );
//Write the FeastsOfStrength into the HTTP-Response
echo "Nnoitra of Gul'dan<br />";
foreach ( $oCharacterPage->Xml->category->achievement as $oAchievement ) {
echo "
<img width='18px' height='18px' src='http://eu.wowarmory.com/wow-icons/_images/51x51/".$oAchievement['icon'].".jpg' />
".$oAchievement['title']."<br />
";
}
Theres also a demo for a client with errorhandling and one with enabled mysqli cache in the download package.
Client in action (shows Feasts of Strength for a character):
http://armorytest.end-game.eu/client_cached.php <-- Sorry, not working anymore after server crash.
Directory:
/ArmoryParser
ArmoryParser.php
Exception.php
/Resolver
Interface.php
Exception.php
StreamContext.php
CUrl.php
/Page
Interface.php
Exception.php
Base.php
Character.php
Achievements.php
/Cache
Interface.php
Exception.php
Base.php
MySqli.php
- ArmoryParser.php The base class.
- Resolver/StreamContext.php Classes under the Resolver directory are the real Armory parser which get the XML stream off the armory. StreamContext uses a simple but working file_get_contents(). You are able to provide your own Resolver as long it's implementing the ResolverInterface.
- Resolver/CUrl.php This uses the code from page 1 of this thread to get the XML and is not tested since I am to dump/lazy to recompile my PHP with cUrl.
- Page/Character.php Use an instance of this class to get characterdata from the Armory. The objects holds the request information (charname, realm, ...) and handles the result. Implement your own Armory pages by creating classes that extends Pages_Base and implements Pages_Interface.
- Page/Achievements.php Same as above. Gets the achievementpage from the Armory.
- cache/MySqli.php A cacheadapter that uses PHP's MySqli extension. Provide a databaseconnection and it will create it's tables itself if needed. Same here - write your own wich extends Cache_Base and implements Cache_Interface ( like MySql or Zend_Db_Table_Abstract ).
It should be really stable due the exceptionhandling (see client.php), but it's a lot of work to do - especially implement more page classes to cover the whole Armory.
I wrote this stuff for my own projects that involve the Armory, but I decided the share the code with the community. As long as there are people wo are interessted in the parser, I can provite updates. The code will elvolve during my current 'in mind' project. If someone wants to contribute, I can offer access to the SVN-Repo (at last i hope so... new to svn). I'm going to implement a public page to compare achievements for guilds with that parser and the ZendFramework in my sparetime.
Here's the source:
http://furizaa.end-game.eu/armory-parser.legacy.tar
**Update 03.10.2010**
Since this code is now over 1 year old and I'm not playing WoW anymore I can't give support on this. But in general it should still work thou.
**End Update**
Rev19: Fixed US-Armory support - for real
Rev18: Fixed US-Armory support
Rev10: First release
If you find this piece of code usefull let me know. If even its just to see what is PHP capable of with a grain of OOP.