-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathusage.php
206 lines (181 loc) · 5.99 KB
/
usage.php
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
// For Timing
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
require_once('diablo3.api.class.php');
// PHP Settings
set_time_limit(0);
error_reporting(E_ALL);
ini_set('memory_limit', '256M');
ini_set('display_errors', true);
/***************************************************************************************/
// Instantiate The Diablo3 Object. Parameters are optional.
// These are some examples ranging from no parameters to all parameters.
//
// Parameter Order: (BattleTag, Server, Locale)
// Brakedown - BattleTag: 'XjSv#1677' or 'XjSv-1677' (string)
// Server: 'us', 'eu' etc. (string)
// Locale: 'en_US', 'pt_BR', 'es_MX', etc. (string)
//
// $Diablo3 = new Diablo3();
// $Diablo3 = new Diablo3("XjSv#1677");
// $Diablo3 = new Diablo3('', 'us');
// $Diablo3 = new Diablo3('', '', 'en_US');
// $Diablo3 = new Diablo3("XjSv#1677", 'us', 'en_US');
//
$Diablo3 = new Diablo3("XjSv#1677");
// Call Available Methods To Return Data.
// In this case since we did not provide a BattleTag we will get
// an error message: 'Function not available without a BattleTag'
//
echo "Career Data:";
$CAREER_DATA = $Diablo3->getCareer();
// Before handling the data check to make sure the return is an array
// If the data is not an array then something wen't wrong.
//
if(is_array($CAREER_DATA)) {
echo '<pre>';
var_dump($CAREER_DATA);
echo '</pre>';
}
// Get Hero Data By ID
//
echo "<br>Hero Data:";
$HERO_DATA = $Diablo3->getHero(3982160);
if(is_array($HERO_DATA)) {
echo '<pre>';
var_dump($HERO_DATA);
echo '</pre>';
}
// Get Item Data
//
echo "<br>Item Data:";
$ITEM_DATA = $Diablo3->getItem('item/COGHsoAIEgcIBBXIGEoRHYQRdRUdnWyzFB2qXu51MA04kwNAAFAKYJMD');
// If caching is enabled you could check if the data came from cache or the API.
// This reflects the last call made to the API.
//
if($Diablo3->resultsFromCache()) {
echo "<br>This data is returned from cache.";
} else {
echo "<br>This data is returned from the API.";
}
if(is_array($ITEM_DATA)) {
echo '<pre>';
var_dump($ITEM_DATA);
echo '</pre>';
}
// Get Item Information Data
//
echo "<br>Item Info Data:";
$ITEM_INFO_DATA = $Diablo3->getItemById('Unique_Helm_006_104');
if(is_array($ITEM_INFO_DATA)) {
echo '<pre>';
var_dump($ITEM_INFO_DATA);
echo '</pre>';
}
// Get Follower Data
// Your options are: 'enchantress', 'templar', 'scoundrel'
//
echo "<br>Follower Data:";
$FOLLOWER_DATA = $Diablo3->getFollower('templar');
if(is_array($FOLLOWER_DATA)) {
echo '<pre>';
var_dump($FOLLOWER_DATA);
echo '</pre>';
}
// Get Artisan Data
// Your options are: 'blacksmith', 'jeweler'
//
echo "<br>Artisan Data:";
$ARTISAN_DATA = $Diablo3->getArtisan('blacksmith');
if(is_array($ARTISAN_DATA)) {
echo '<pre>';
var_dump($ARTISAN_DATA);
echo '</pre>';
}
/***************************************************************************************/
/***************** Images & ToolTips (not part of the official API) ********************/
// Get Item Image
// Parameter Order: (Icon Name, Size)
// Brakedown - Name: 'unique_chest_013_104_demonhunter_male', etc.
// Size: 'small' or 'large'
// Returns the location of the image or false on failure.
//
echo "<br>Item Image: <br>";
$ITEM_IMAGE = $Diablo3->getItemImage('unique_chest_013_104_demonhunter_male', 'large');
if(!empty($ITEM_IMAGE)) {
echo '<img src="'.$ITEM_IMAGE.'">';
}
// Get Skill Image
// Parameter Order: (Icon Name, Size)
// Brakedown - Name: 'barbarian_frenzy', etc.
// Size: '21', '42' or '64'
// Returns the location of the image or false on failure.
//
echo "<br>Skill Image: <br>";
$SKILL_IMAGE = $Diablo3->getSkillImage('barbarian_frenzy', '64');
if(!empty($SKILL_IMAGE)) {
echo '<img src="'.$SKILL_IMAGE.'">';
}
// Get PaperDoll Image
// Parameter Order: (Class, Gender)
// Brakedown - Class: 'barbarian', 'witch-doctor', 'demon-hunter', 'monk' or 'wizard'
// Gender: 'male' or 'female'
// Returns the location of the image or false on failure.
//
echo "<br>Paperdoll: <br>";
$PAPERDOLL = $Diablo3->getPaperDoll('barbarian', 'female');
if(!empty($PAPERDOLL)) {
echo '<img src="'.$PAPERDOLL.'">';
}
// Get All Item Images for 1 Hero
// Parameter Order: (Hero ID, Size)
// Brakedown - Name: 'unique_chest_013_104_demonhunter_male', etc.
// Size: 'small' or 'large'
// Returns true on success.
//
$allItemImages = $Diablo3->getAllHeroItemImages(3982160, 'small');
if($allItemImages) {
echo "<br>All Hero Item Images Saved";
}
// Get All Skill Image for 1 Hero
// Parameter Order: (Hero ID, Size)
// Brakedown - Hero ID: 3982160
// Size: 21, 42 or 64
// Returns true on success.
//
$allSkillImages = $Diablo3->getAllHeroSkillImages(3982160, 42);
if($allSkillImages) {
echo "<br>All Hero Skill Images Saved";
}
// Get ToolTip Skill Data (for javascript handling)
// Parameter Order: (tooltipUrl, boolean)
// Brakedown - tooltipUrl: 'skill/barbarian/frenzy', etc.
// Boolean: true for jsonp, false or leave empty for json.
//
echo "<br>Skill Tooltip: <br>";
$SKILL_TOOLTIP = $Diablo3->getSkillToolTip('skill/barbarian/frenzy', true);
if(!empty($SKILL_TOOLTIP)) {
echo $SKILL_TOOLTIP;
}
// Get ToolTip Rune Data (for javascript handling)
// Parameter Order: (tooltipUrl, boolean)
// Brakedown - tooltipUrl: 'rune/frenzy/a', etc.
// Boolean: true for jsonp, false or leave empty for json.
//
echo "<br>Skill Rune Tooltip: <br>";
$SKILL_RUNE_TOOLTIP = $Diablo3->getSkillToolTip('rune/frenzy/a');
if(!empty($SKILL_RUNE_TOOLTIP)) {
echo $SKILL_RUNE_TOOLTIP;
}
/***************************************************************************************/
// For Timing
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
$total_memory = round((memory_get_usage() / 1048576), 2); // Calculate Memory Usage Based on MB
echo "<br>Proccess finished in {$total_time} seconds<br>Memory Used: {$total_memory} MB";