marenkay / phparmory

phpArmory is a PHP class library that can easily fetch and unserialize World of Warcraft Armory XML data into structured associative arrays.

This URL has Read+Write access

phparmory / examples / guildData.php
100644 88 lines (74 sloc) 2.291 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* phpArmory5 test case
*
* A test case to derive a new class object from the phpArmory5 class.
* @package phpArmory
* @subpackage tests
*/
 
// Include the phpArmory class library
require_once ('../phpArmory.class.php');
 
 
$areaName = 'eu';
$guildName = "Divinitas";
$guildRealmName = "Madmortem";
 
$sapi_type = substr(php_sapi_name(), 0, 3);
 
// Instantiate the class library
if ( $armory = new phpArmory5($areaName = $areaName) ) {
 
    $guildData = $armory->getGuildData($guildName, $guildRealmName);
    if ($sapi_type == 'cli') {
        var_dump ($guildData);
    } else {
    // Define some variables
    $guildName = $guildData['guildinfo']['guild']['name'];
    $guildMemberCount = $guildData['guildinfo']['guild']['members']['membercount'];
    $guildCharacters = $guildData['guildinfo']['guild']['members']['character'];?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$guildName;?> Roster</title>
</head>
 
<body>
 
<h1><?=$guildName;?> Roster</h1>
<h2><?=$guildMemberCount;?> Members</h2>
 
<table>
<caption>Guild Members</caption>
<thead>
<tr>
<th>Name</th>
<th>Level</th>
<th>Race</th>
<th>Class</th>
<th>Gender</th>
<th>Rank</th>
<th>Portrait</th>
</tr>
</thead>
<tbody>
<?php
 
foreach($guildCharacters as $char){
    $char = $char;
?>
<tr>
<td><?=$char['name'];?></td>
<td><?=$char['level'];?></td>
<td><?=$char['race'];?></td>
<td><?=$char['class'];?></td>
<td><?=$char['gender'];?></td>
<td><?=$char['rank'];?></td>
<td><img src="<?=$armory->getCharacterIconURL($char);?>" alt="" /></td>
</tr>
<?
 
}
 
?>
</tbody>
</table>
<p>Data scraped from the official World of Warcraft Armory (<?=$armory->armory;?>)</p>
</body>
</html>
<?php
    }
} else {
    echo "Failed to create a phpArmory5 instance.\n";
}
 
?>