PHP WoW Battle.net Armory API assistance

90 Night Elf Priest
12005
My php skills are between noob and amateur. I'm using the library from Growar https://sourceforge.net/projects/wowarmoryapi/

I can't quite figure out how to pull data from the db once it's been cached. It was suggested on stack overflow to use json_decode but I'm getting an error: Trying to get property of non-object.

Here is my stackoverflow question for more information: http://stackoverflow.com/questions/16344399/php-wow-battle-net-armory-api-library-pulling-data-from-cache-in-db

Any assistance here or on s.o. would be lovely!
Reply Quote
90 Night Elf Monk
11335
You pull your data from the cache the same way that you get it in there, and it depends on the data you're trying to pull.

I too use Growar's php api, and it's relatively easy to use.

first, setup the api to point it's db cache to a database you've created for the cache (sounds like you've done that)

Secondly, load the api into your php page (sound like you're ok here too)

Now you're ready to pull information from the api. Let's start with a character:


$armory = new BattlenetArmory('us','draenor');

$character = $armory->getCharacter('vester');


Now I have an object $character which contains all of the data that is provided for the character object from the blizzard API. Growar's api has done all of the heavy lifting in that it's pulled all of the json feeds from blizzard and stored them into my "local" database, so if I call $armory->getCharacter('vester') again, rather than going out to the blizzard api and pulling down all that information (character stats, achievements, pets, mounts, etc) the api checks to see if it is cached and returns your information that way.

Browse through the character.class.php file and you can see all of the public methods for which you can return into your PHP code to display. Things like character name, level, race, class, guild membership, etc. Once you have a feel for the data that's being returned, what's required etc. you're well on your way to creating quite a !@#$%in' website. Then, as your skills improve and you become more brave, and as you use the API you'll notice that some information you'd like to pull isn't provided. That's when you start diving into the separate classes and start adding your own methods. For example: Growar's api doesn't have any type of raid progression within the character api, I wanted such an option in my website and had to write my own methods within the character class in order to accomplish it.

I'll leave you with a quick and dirty example of how to pull some simple information about your character:


//init the bnet armory api
$armory = new BattlenetArmory('us','draenor');

//grab a character
$character = $armory->getCharacter('vester');

$charName = $character->getCharacterName();
$charLevel = $character->getCharacterLevel();
$charGuild = $character->getCharacterGuild();


HTH
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)
Submit Cancel

Reported!

[Close]