Question

I am using this library: https://sourceforge.net/p/wowarmoryapi/home/Home/ which seriously lacks documentation. The forums there are mostly unanswered.

I've been able to successfully pull data from battle net's armory, specifically guild information. It is then stored in the wa_guilds table as a large blob in a row called Data. From there I'm unsure how to pull it and display it. I've tried the code below and about 100 different variations of that as well as unserialize but I'm too inexperienced. This is just past my level of knowledge.

My Error: Notice: Undefined index: object I've tried name, level, rank

New error caused by print $roster->character;: "Notice: Trying to get property of non-object"

My code:

<?php
include('_inc.php'); // shh I'm hunting wabbits
$conn = mysqli_connect("localhost", "root", "")
    or die(mysql_error());
mysqli_select_db($conn, "wow")
    or die(mysql_error());
$data = mysqli_query($conn, "SELECT Data FROM wa_guilds") or die(mysql_error());

//echo $data;

print "<table border cellpadding=3>"; 
while($info = mysqli_fetch_array( $data, MYSQLI_BOTH )) 
{   
    $roster = json_decode($info[0]);
    print $roster->character;
} 
print "</table>";

//$array = explode(',', $data);
//echo $array[0];

?>

It looks like a popular library so I'm hoping someone has experience with it.

Some data from var_dump:

array(2) { [0]=> string(100000) "{"lastModified":1367433943000,"name":"Teh Fail","realm":"Zul'jin","battlegroup":"Ruin","level":25,"side":1,"achievementPoints":1195, [{"character":{"name":"Mundi","realm":"Zul'jin","battlegroup":"Ruin","class":8,"race":8,"gender":0,"level":85,"achievementPoints":12855,"thumbnail":"zuljin/65/3357249-avatar.jpg","guild":"Teh Fail","spec":{"name":"Fire","role":"DPS","backgroundImage":"bg-mage-fire","icon":"spell_fire_firebolt02","description":"Ignite enemies with balls of fire and combustive flames.","order":1}},"rank":3},{"character":{"name":"Kekeke","realm":"Zul'jin","battlegroup":"Ruin","class":4,"race":8,"gender":0,"level":85,"achievementPoints":11345,"thumbnail":"zuljin/76/3359564-avatar.jpg","guild":"Teh Fail","spec":{"name":"Combat","role":"DPS","backgroundImage":"bg-rogue-combat","icon":"ability_backstab","description":"A swashbuckler who uses agility and guile to stand toe-to-toe with enemies.","order":1}},"rank":3},{"character":{"name":"Benth","realm":"Zul'jin","battlegroup":"Ruin","class":9,"race":5,"gender":0,"level":90,"achievementPoints":13165,"thumbnail":"zuljin/252/3364348-avatar.jpg","guild":"Teh Fail","spec":{"name":"Destruction","role":"DPS","backgroundImage":"bg-warlock-destruction","icon":"spell_shadow_rainoffire","description":"A master of chaos who calls down fire to burn and demolish enemies.","order":2}},"rank":3}

Edit: Changed mysqli database connection lines to PDO and all is well.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top