/** * Constructor for a Hero * * @param string $battlenetTag * @param integer $id * @param array $info * @throws InvalidArgumentException * @return void */ public function __construct($battlenetTag, $id, $info = array()) { parent::__construct($battlenetTag); if ($id == '') { throw new InvalidArgumentException('Id cannot be empty'); } else { $this->id = $id; if (!empty($info)) { foreach ($info as $key => $value) { $this->{$key} = $value; } } } }
/** * * Get all Diablo 3 item images. * **/ $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; require_once '../class/diablo3.api.class.php'; require_once '../config/settings.php'; require_once '../include/functions.php'; set_time_limit(0); ini_set('memory_limit', '256M'); $Diablo3 = new Diablo3(BATTLENET_ACCOUNT, DEFAULT_SERVER, DEFAULT_LOCALE); $connection = new Mongo(); $db = $connection->selectDB(PROD_DB); $all_items = $db->command(array("distinct" => ITEM_COLLECTION, "key" => "icon")); $count = 0; // Download Small Images // foreach ($all_items['values'] as $item) { $count++; $Diablo3->getItemImage($item, 'small'); } // Download Large Images // foreach ($all_items['values'] as $item) { $count++; $Diablo3->getItemImage($item, 'large');
/** * * Get all Diablo 3 item images. * **/ $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; require_once '../class/diablo3.api.class.php'; require_once '../config/settings.php'; require_once '../include/functions.php'; set_time_limit(0); ini_set('memory_limit', '256M'); $Diablo3 = new Diablo3(BATTLENET_ACCOUNT, DEFAULT_SERVER, DEFAULT_LOCALE); $connection = new Mongo(); $db = $connection->selectDB(PROD_DB); $hero_collection = $db->selectCollection(HERO_COLLECTION); $all_heros = $hero_collection->find(); $count = 0; $skills = array(); // Build Skills List // foreach ($all_heros as $hero) { foreach ($hero['skills']['active'] as $key => $value) { if (isset($value['skill']['icon']) && !empty($value['skill']['icon'])) { $skills[$value['skill']['icon']] = 1; } } foreach ($hero['skills']['passive'] as $key => $value) {
<?php // For timing $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; // For timing require_once 'diablo3.api.class.php'; // Settings set_time_limit(0); ini_set('memory_limit', '128M'); $Diablo3 = new Diablo3("XjSv#1677", 'us', 'en_US'); // Battle Tag (e.g. 'XjSv#1677' or 'XjSv-1677') (string), Server: 'us', 'eu', etc. (string), Locale: 'en_US', 'es_MX', etc. (string) $CAREER_DATA = $Diablo3->getCareer(); $HERO_DATA = $Diablo3->getHero(3982160); // Hero ID (int) $ITEM_DATA = $Diablo3->getItem('item/COGHsoAIEgcIBBXIGEoRHYQRdRUdnWyzFB2qXu51MA04kwNAAFAKYJMD'); // Item Data 'item/COGHsoAIEgcIBBXIGEoRHYQRdRUdnWyzFB2qXu51MA04kwNAAFAKYJMD' (string) $FOLLOWER_DATA = $Diablo3->getFollower('templar'); // Options: 'enchantress', 'templar', 'scoundrel' (string) $ARTISAN_DATA = $Diablo3->getArtisan('blacksmith'); // Options: 'blacksmith', 'jeweler' (string) $ITEM_IMAGE = $Diablo3->getItemImage('unique_chest_013_104_demonhunter_male', 'large'); // Icon Name, Size: Options: 'small', 'large' (string) $SKILL_IMAGE = $Diablo3->getSkillImage('barbarian_frenzy', '64'); // Icon Name, Size: Options: '21', '42', '64' (string) $SKILL_TOOLTIP = $Diablo3->getSkillToolTip('skill/barbarian/frenzy', true); // tooltipUrl, true for jsonp $SKILL_RUNE_TOOLTIP = $Diablo3->getSkillToolTip('rune/frenzy/a', false); // tooltipUrl, true for jsonp
$item_collection = $db->selectCollection(ITEM_COLLECTION); $app_stats_collection = $db->selectCollection(APP_STATS_COLLECTION); if (!$test_mode) { $career_collection->ensureIndex(array("battleTag" => 1, "lastUpdated" => 1, "_region" => 1), array("unique" => 1, "dropDups" => 1)); $hero_collection->ensureIndex(array("id" => 1, "last-updated" => 1), array("unique" => 1, "dropDups" => 1)); $item_collection->ensureIndex(array("id" => 1, "tooltipParams" => 1), array("unique" => 1, "dropDups" => 1)); } foreach ($user_profiles as $item) { foreach ($item as $region => $user) { $time2 = microtime(); $time2 = explode(' ', $time2); $time2 = $time2[1] + $time2[0]; $start2 = $time2; // GET CAREER // $Diablo3 = new Diablo3($user, $region, DEFAULT_LOCALE); // Battle.net Tag. (e.g. 'XjSv#1677' or 'XjSv-1677') (string), Server: 'us', 'eu', etc. (string) [Optional, Defaults to 'us'], Locale: 'en', 'es', etc. (string) $CAREER_DATA = $Diablo3->getCareer(); $calls++; if (is_array($CAREER_DATA)) { // MAKE HERO LIST // $hero_list = array(); foreach ($CAREER_DATA['heroes'] as $key => $value) { $hero_list[] = $value['id']; } // GET HERO DATA // $HERO_DATA = array(); foreach ($hero_list as $key => $hero) { $HERO_DATA[] = $Diablo3->getHero($hero);
<?php require_once 'class/diablo3.api.class.php'; require_once 'config/settings.php'; require_once 'include/functions.php'; session_start(); $tooltipUrl = $_GET['tooltipUrl']; if (isset($_SESSION['ITEM'][$tooltipUrl])) { $DATA_RETURN = $_SESSION['ITEM'][$tooltipUrl]; } else { $Diablo3 = new Diablo3(BATTLENET_ACCOUNT, DEFAULT_SERVER, DEFAULT_LOCALE); $DATA_RETURN = $Diablo3->getSkillToolTip($tooltipUrl, false); $_SESSION['ITEM']['tooltipUrl'] = $DATA_RETURN; } echo $DATA_RETURN;
// 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("bogdan#1980"); // 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' // $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 went wrong. // if (!is_array($CAREER_DATA)) { echo 'Error.'; echo '<pre>'; var_dump($CAREER_DATA); echo '</pre>'; die; }