Home

Thomas Andersen
There is a newer version of this page. You can find it here.

PHP WoW Battle.net Armory API

Disclaimer: This is my first time with a project on sourceforge, so if I'm doing anything wrong please let me know so I can fix it.

[Changelog]
Planned features and changes

Intro

Ever since the World of Warcraft armory moved to battle.net it's been easier to extract information. The armory is under constant development, and some areas are still in beta or not created yet, which is why they will be missing from this API.

DONATIONS: Someone has actually asked me where to donate for the work. Using PayPal, you can just use my email address acoon(at)acoon.dk

Features

  • Extract all information from Battle.net armory
  • Handles guilds, characters and items.
  • WoW Head integration for extracting remaining information like achievement names
  • WoW Head integration for easy tool tip links
  • Full cache to limit connections and ensure speedy information
  • Generates emblems based on guild tabard design
  • Add your guild level to the emblem
  • Built in sorting and filtering
  • and much much more..

Requirements

  • PHP 5.x
  • MySQL 5.x
  • Programming knowledge
  • Internet connection

Installation

  • Download the latest package
  • Unpack the files where you may need them.
  • Make sure the webserver has write permission in the cache folder

Usage

Where ever you want to use this api you will need to include BattlenetArmory.class.php. This is the primary class, and it will include the rest of the class files.

<?php
    $GLOBALS['wowarmory']['db']['driver'] = 'mysql'; // Dont change. Only mysql supported so far.
    $GLOBALS['wowarmory']['db']['hostname'] = '127.0.0.1'; // Hostname of server. 
    $GLOBALS['wowarmory']['db']['dbname'] = ''; //Name of your database
    $GLOBALS['wowarmory']['db']['username'] = ''; //Insert your database username
    $GLOBALS['wowarmory']['db']['password'] = ''; //Insert your database password
    // Only use the two below if you have received API keys from Blizzard.
    $GLOBALS['wowarmory']['keys']['private'] = '';
    $GLOBALS['wowarmory']['keys']['public'] = '';
    include('BattlenetArmory.class.php');
?>

After you include that file you better use it. :) The best way is to show a small example code. This will show all the possible functions that are available.

<?php
    //include the main class 
    include('BattlenetArmory.class.php'); 

    // Load the class and define the realm and region 
    $armory = new BattlenetArmory('EU','Defias Brotherhood'); 

    // Enable this is if toons with special characters break the API.
    // $armory->UTF8(TRUE);

    // Load all the guild data into an object. This is NOT an array 
    $guild = $armory->getGuild('Shadowsong'); 

    // Load all the character data into an object. This is NOT an array 
    $character = $armory->getCharacter('Growar'); 
?>

This will give you two objects: guild and character. Within these you will find different functions to call, that will mainly return an array with the information you need.

Guild Object

Load the guild

<?php
    // Initialize the guild object
    $guild = $armory->getGuild('Shadowsong');

    // Get an array with all members and basic information
    $members = $guild->getMembers();

    // Get an array with all members and basic information sorted
    // sort can be name|class|race|gender|level|rank
    // sortflag can be asc | desc
    $members = $guild->getMembers('name','asc');

    // Get array the guild achievements.
    // Also includes wowhead urls and names for easy integration with wowhead tooltip
    // Include this to get tooltip on URLS:
    // <script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script>
    $achievements = $guild->getAchievements();

    // Get array the guild achievements sorted
    // sort can be timestamp|id|name
    // sortflag can be asc | desc
    $achievements = $guild->getAchievements('timestamp','desc');

    // Generate and output a guild emblem png. This sohuld be run from a separate php file.
    $guild->showEmblem()

    // Generate and output a guild emblem png. This sohuld be run from a separate php file.
    // showlevel can be TRUE|FALSE. It is TRUE by default.
    // width can be 1-215
    $guild->showEmblem(FALSE,'175');

    // Get all data function where it will just dump it all to you in an array
    $data = $guild->getData();
?>

As a cool side feature you can make your own guild emblem with just a few lines. This will respond with and image meaning this is all that should be in the php file.

<?php
    include('BattlenetArmory.class.php');
    $armory = new BattlenetArmory('EU','Defias Brotherhood');
    $guild = $armory->getGuild('Shadowsong');
    // Takes two parameters to disable level and resize. 
    // $guild->showEmblem(FALSE,125);
    $guild->showEmblem();
?>

Character Object

<?php
    // Get the character object
    $character = $armory->getCharacter('Growar');

    // Return the amount of achievement points for the loaded character
    $achievementpoints = $character->getAchievementPoints();

    // Return all achievements completed for the character.
    $achievements = $character->getAchievements();
    // Return all achievements completed for the character sorted.
    // sort can be timestamp|id|name
    // sortFlag Can be asc|desc
    $achievements = $character->getAchievements('timestamp','desc');

    // If the character is not member of any team, this will return FALSE
    // Else it will return an array with 1-3 teams.
    $arenateams = $character->getArenaTeams();

    // Get the rated battleground personal rating
    $battlegroundPersonalrating = $character->getBattlegroundRating();

    // Get stats on all the character rated battlegrounds
    $battlegrounds = $character->getBattlegrounds();

    // Get a list of the completed achievements by the guild
    // WARNING: Since this also make lookups at wowhead, it can be very slow. However it will cache
    $completedquests = $character->getCompletedQuests();
    // sort defines what the list should be sorted by: id|name
    // sortFlag can be asc|desc
    $completedquests = $character->getCompletedQuests('name','asc');

    // Get the number of quests completed by the character
    $completedquestsAmount = $character->getCompletedQuestsAmount();

    // Get the full currently used title
    $title = getCurrentTitle();
    // withName Set to FALSE if you want to use the %s instead of name
    // Will replace name with %s
    $title = getCurrentTitle(FALSE);

    // Get character faction. Returns 1 for alliance and 2 for horde
    $faction = $character->getFaction();

    // Return an array with equipped gear and itemlevel stats.
    $gear = $character->getGear();

    // Get the amount of honor kills
    $honorkills = $character->getHonorKills();

    // Get the character level
    $level = $character->getLevel();

    // Retrieve the characters mounts
    $mounts = $character->getMounts();

    // Get the character professions
    $professions = $character->getProfessions();

    // Retrieve the raid kills from the character
    $raidprogress = $character->getRaidStats();
    // sort Can be asc | desc. Default is asc
    $raidprogress = $character->getRaidStats('desc');

    // Get character reputations
    $reputation = $character->getReputation();
    // sort Use to enable sorting
    // sortfield Define the field you want to sort by - Values are: id | name | standing
    // order Define the order of the sorting - Values are: desc | asc
    $reputation = $character->getReputation(TRUE,'standing','desc');

    // Retrieve stats such as HP,mana,AP,AGIhit,parry etc.
    $stats = $character->getStats();

    // Returns the complete URL for a character thumbnail
    $thumbnailurl = $character->getThumbnailURL();

    // Get all the titles held by the character
    $titles = $character->getTitles();

    // Check if the character has been loaded correctly
    $validcharacter = $character->isValid();
?>

AuctionHouse Object

<?php
    $auctionhouse = $armory->getAuctionHouse();
    $auctions = $auctionhouse->getData();
?>

Realms Object

<?php
    // Load the realms. Since it's the same request to get one or all realms,
    // all is cached.
    $realms = $armory->getRealms();

    // Return the specific realm you want. Will take it from cache when object was created.
    $myrealm = $realms->getRealm('Defias Brotherhood');
?>

Item Object

<?php
    // Load the realms. Since it's the same request to get one or all realms,
    // all is cached. This will load weapon 'Legacy'
    $item = $armory->getItem(28587);

    // Get the name of the item.
    $itemname = $item->getName();

    // Get icon URL for the item
    $itemurl = $item->getIcon();
    // Get icon URL for the item at the size 36 px. Valid values are 18 | 36 | 56. 56 is default.
    $itemurl = $item->getIcon(36);


    // Get a IMG tag with alot of inline style for adding icon border, light etc. Unfinished.
    $itemIMG = $item->getIconIMGtag();
    // Same, but for Firefox and a different size. Same sizes as getIcon().
    // Browser can be 'ie' or 'moz'
    $itemIMG = $item->getIconIMGtag(36,'moz');

?>

Cache Control

Made a switch to MySQL in version 3.0

<?php
    // Turn off cache. Using this you dont have to define MySQL user/pass/etc,
    // but will generate quite a few calls to blizzard if you are not careful.
    // Added it because some users had their own cache to control
    $armory->useCache(FALSE)
?>

Page still in progress


MongoDB Logo MongoDB