<?php
//This php file is built to pull armory data from the World of Warcraft Amory site.
//Built by: Zxile - Drenden US
//Built mainly for Lhivera's Mage Theorycraft-o-Matic
//This document requires php 5, due to the use of the SimpleXML parser.
//Function: pull_stats
//Takes 3 variables
//name = Name of the character
//Server = Server the character is located on. Note: This function automatically converts Server Names with spaces into url compatiable strings
//Region = US or EU
//----------------------------
//Returns
//false; if the character is not found
//Stats array; if character was present.
function pull_stats($name, $realm, $region='us') {
//Decide between EU and US armory sites.
if($region == 'eu') {
$baseurl = 'http://eu.wowarmory.com/';
}
else {
$baseurl = 'http://www.wowarmory.com/';
}
//$server = str_replace(' ', '+', $server);//Replace spaces with +
//ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6'); //Set User Agent to make armory page think we're calling from a browser, GG Blizzard
ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6'); //Set User Agent to make armory page think we're calling from a browser, GG Blizzard
$character_url = $baseurl . "character-sheet.xml?r=" . urlencode(stripslashes($realm)) . "&n=" . urlencode(stripslashes($name));
$talents_url = $baseurl . "character-talents.xml?r=" . urlencode(stripslashes($realm)) . "&n=" . urlencode(stripslashes($name));
echo "$character_url<br>";
//$queryurl = $baseurl . 'character-sheet.xml?r=' . $server . '&n=' . $name; //Setup URL for Query
//$queryurl2 = $baseurl . 'character-talents.xml?r=' . $server . '&n=' . $name; //Setup URL for Query
//$xmldoc = simplexml_load_file($queryurl); //Pull Stat data from Armory
$char = simplexml_load_file($character_url);
//$xmldoc2 = simplexml_load_file($queryurl2);
$talents = simplexml_load_file($talents_url);
if($char->characterInfo['errCode'] == 'noCharacter' ) {
echo "Character not found.<br>";
return false; //Character not found
} else { //Parse Stats
$stats = array(); //instantiate the array
$chardata = $char->characterInfo->character;
//Race
$stats['Race'] = (string) $chardata['race'];
$stats['Class'] = (string) $chardata['class'];
$stats['GuildName'] = (string) $chardata['guildName'];
$statsdata = $char->characterInfo->characterTab; //Root of charcter data
//Base Stats
$stats['GuildName'] = (string) $char->characterInfo->character['guildName'];
$stats['Stamina'] = (string) $statsdata->baseStats->stamina['effective'];
$stats['Intellect'] = (string) $statsdata->baseStats->intellect['effective'];
$stats['Spirit'] = (string) $statsdata->baseStats->spirit['effective'];
$stats['Strength'] = (string) $statsdata->baseStats->strength['effective'];
$stats['Agility'] = (string) $statsdata->baseStats->agility['effective'];
//Spell Stats (Dmg, Crit, Hit)
$stats['Arcane Damage'] = (string) $statsdata->spell->bonusDamage->arcane['value'];
$stats['Fire Damage'] = (string) $statsdata->spell->bonusDamage->fire['value'];
$stats['Frost Damage'] = (string) $statsdata->spell->bonusDamage->frost['value'];
$stats['Shadow Damage'] = (string) $statsdata->spell->bonusDamage->shadow['value'];
$stats['Nature Damage'] = (string) $statsdata->spell->bonusDamage->nature['value'];
$stats['Holy Damage'] = (string) $statsdata->spell->bonusDamage->holy['value'];
$stats['Healing'] = (string) $statsdata->spell->bonusHealing['value'];
$stats['Spell Hit Rating'] = (string) $statsdata->spell->hitRating['value'];
$stats['Spell Crit Rating'] = (string) $statsdata->spell->critChance['rating'];
//NOTE: Spell Haste is not yet supported in the WoW Armory
//Pull Spec Information
$specstring = (string) $talents->characterInfo->talentTab->talentTree['value'];
$stats['Arcane Mind'] = substr($specstring, 14, 1);//Arcane Mind points
$stats['Mind Mastery'] = substr($specstring, 21, 1);//Arcane Mind points
$stats['Arcane Pts'] = (string) $statsdata->talentSpec['treeOne'];
$stats['Fire Pts'] = (string) $statsdata->talentSpec['treeTwo'];
$stats['Frost Pts'] = (string) $statsdata->talentSpec['treeThree'];
$buffsdata = $char->characterInfo->characterTab->buffs;
$buffs = array();
$i = 0;
while (1) {
if ($buffsdata->spell[$i]) {
$buffs[] = $buffsdata->spell[$i]['name'];
$i++;
} else {
break;
}
}
$stats['Buffs'] = $buffs;
return $stats;
}
}//end Function pull_stats
?>