Greetings warmane community,
Before i start i want to thank a guy that started one thread ive seen long time ago where he posted website template with css already. Im Sorry i cant recall either thread link nor name. But if u r reading this, please tag yourself with a comment.
What is exactly an api?
You can think of API as a resource, a resource that is made by developers for you to use it and make an output with such resources.
When it comes to warmane api, you get to have a huge json string or an array that will be displayed once you open an api URL such as:
http://armory.warmane.com/api/guild/...stwolf/summary (example of my guild)
https://i.gyazo.com/4ce4436d8f8cd529...50c821b2ca.png
You can notice that alot of player informations is there and free to use it on your external website or any kind of application.
What can i do with warmane API?
You can make a guild roster of your own that is fully automated as players join guild or leave.
You can check whether the player is online or offline.
You can display player informations such as race,level,achievement points, equipment, spec, professions,...
Few images of how something like that looks like when warmane api is used.
Guild roster:
https://i.gyazo.com/b5241ab2830d8d35...48c693b255.png
Player Armory:
https://i.gyazo.com/8fa9166ef8f328f4...bd0cce0d32.png
How do i use API?
index.php
user_info.phpCode://Before the hmtl tag begin.
//Rename "The+Sanctuary" with your guild name.
<?php
$json_string = file_get_contents("https://armory.warmane.com/api/guild/The+Sanctuary/Frostwolf/members");
$guild_string = json_decode($json_string);
//TRANSLATIONS
$var_name = "Name";
$var_race = "Race";
$var_class = "Class";
$var_level = "Level";
$var_achievementpoints = "Achievement Points";
$var_online = "Status";
?>
//In HTML body tag.
<html>
<body>
<table class="sortable">
<thead>
<tr>
<th><?php echo $var_online; ?></th>
<th><?php echo $var_name; ?></th>
<th><?php echo $var_race; ?></th>
<th><?php echo $var_class; ?></th>
<th><?php echo $var_level; ?></th>
<th><?php echo $var_achievementpoints; ?></th>
</tr>
</thead>
<tbody>
<?php
//Decoding json string into an array.
$guild_roster = json_decode($json_string, true);
$guild_roster = $guild_roster['roster'];
//Looping trought an array and using its values.
foreach($guild_roster as $key => $value)
{
echo '<tr>';
echo '<td>' .($value['online'] > 0 ? "<font color='green'>Online</font>" : "<font color='red'>Offline</font>" ). '</td>';
//What i did in next line of code is a link on a name to open a new page with user information. In my case the page is called
user_info.php with an ID extension which will be name, so its auto set for each name.(Check user_info.php tutorial how to fetch ID)
echo '<td><a href="user_info.php?id=' . $value['name'] . '">' . $value['name'] . '</a></td>';
echo '<td>' . $value['race'] . '</td>';
echo '<td>' . $value['class'] . '</td>';
echo '<td>' . $value['level'] . '</td>';
echo '<td>' . $value['achievementpoints'] . '</td>';
echo '</tr>';
echo '</a>';
}
?>
</tbody>
</table>
</body>
</html>
The viewmodel itself is just an iframe from warmanes armory. This is how i extracted it with iframeCode:
//Before HTML tag.
<script type="text/javascript" src="http://cdn.cavernoftime.com/api/tooltip.js"></script>
<?php
//In next 3 lines u can see how fetching an ID as a name works when its clicked on name of player at index table.So after we fetch it we push it to link so its generated for each name(at line 4)
$url = $_SERVER['REQUEST_URI'];
$url = explode("=", $url);
$id = $url[count($url) - 1];
$json_string = file_get_contents('http://armory.warmane.com/api/character/'.$id. '/Frostwolf/profile');
$player_string = json_decode($json_string);
?>
//In HTML tag
<html>
<head>
<script>
var CoTTooltips = {
/* Enable or disable the rename of URLs into item, spell and other names automatically */
rename: true,
/* Enable or disable icons appearing on the left of the tooltip links. */
icons: true,
/* Overrides the default icon size of 15x15, 13x13 as an example, icons must be true */
iconsize: 15,
/* Enable or disable link rename quality colors, an epic item will be purple for example. */
qualitycolor: true,
/* TBA */
forcexpac: { },
/* Override link colors, qualitycolor must be true. Example: spells: '#000' will color all renamed spell links black. */
overridecolor: {
spells: '',
items: '',
npcs: '',
objects: '',
quests: '',
achievements: ''
}
};
</script>
</head>
<body>
<table>
<thead>
<tr>
<th align="center"><?php echo 'GEAR'; ?></th>
<th align="center"><?php echo 'MODEL VIEWER' ?></th>
<th align="center"><?php echo 'PLAYER INFORMATION' ?></th>
</tr>
</thead>
<tbody>
<?php
//Equipment of player
$player = json_decode($json_string, true);
$player = $player['equipment'];
foreach($player as $key => $value)
{
echo '<tr>';
//This "a" link is basicly a warmanes cavernoftime tooltip and color changer.
echo '<td><a href="http://mop.cavernoftime.com/item=' . $value['item'] . '">' . $value['name'] . '</a></td>';
echo '</tr>';
}
?>
</tbody>
</table>
//List that i use for player information right from viewmodel.
<div class="playerinfo"">
<ul class="list-group">
<li class="list-group-item">Player name: <?php echo $player_string->name; ?> </li>
</br>
<li class="list-group-item">Race: <?php echo $player_string-->race; ?> </li>
</br>
<li class="list-group-item">Class: <?php echo $player_string-->class; ?> </li>
</br>
<li class="list-group-item">Level: <?php echo $player_string-->level; ?> </li>
</br>
<li class="list-group-item">Gender: <?php echo $player_string-->gender; ?> </li>
</br>
<li class="list-group-item">Honorable Kills: <?php echo $player_string-->honorablekills; ?></li>
</br>
<li class="list-group-item">Achievements: <?php echo $player_string-->achievementpoints; ?></li>
</br>
<li class="list-group-item">Professions:
<?php
//Professions and skill
$player= json_decode($json_string, true);
$player= $player['professions'];
foreach($player as $key => $value)
{
echo '<ul>';
echo '<li>';
echo $value['name'];
echo '(';
echo $value['skill'];
echo ') ';
echo '</li>';
echo '</ul>';
}
?>
</li>
</br>
<li class="list-group-item">Specializations:
<?php
//Player talents.
$player = json_decode($json_string, true);
$player = $player['talents'];
foreach($player as $key => $value)
{
echo $value['tree'];
echo ', ';
}
?>
</li>
</ul>
</div>
</body>
</html>
If you have any questions please comment bellow and ill try to answer asap.Code:
//Im sure there was better way and more clear ,but i just wanted it to be done fast :D
<div style="position:relative;width:410px;height:1000px; float:right;margin-top:10%;margin-right:-2%;z-index:1" align="right">
<div align="right" style="overflow: hidden; margin-top: -0px; margin-left: 35px;margin-right:50px;z-index:1">
<iframe scrolling="no" align="right" src="<?php echo "http://armory.warmane.com/character/" .$id . "/Frostwolf/profile" ?>" style="border: 0px none; margin-left: -0px; height: 983px; margin-top: -557px; width: 411px;z-index:2>" html=""></iframe>
</div>
</div>