[WoW] Sample API Calls for PHP (editable)

API Discussion
This sample file can be edited and saved as a PHP file, then ran on your website. You will have to edit the following fields with the appropriate info for your own needs.

File Link: https://www.kotsh.org/free/wow_api_sample.zip

Example:$RegionName = 'us';
$LocaleName = 'en_US';
$GameName = 'wow';

$RealmName = str_replace(' ', '%20', 'Proudmoore');
$GuildName = str_replace(' ', '%20', 'Order of the Silver Hand');
$PlayerName = 'Thëödïcüs';

Actual Code:<?php
header('Content-type: text/html; charset=utf-8');

//----------------------------------------------//
//-- Edit These Values With Your Information --//
//--------------------------------------------//

//-- Your Registered API Key --//
$APIkey = '<your_api_key>';

//-- Your Region, Locale & Game --//
$RegionName = '<region_name>';
$LocaleName = '<locale_name>';
$GameName = '<game_name>';

//-- Your Realm, Guild & Player Name --//
$RealmName = str_replace(' ', '%20', '<realm_name>');
$GuildName = str_replace(' ', '%20', '<guild_name>');
$PlayerName = '<player_name>';

//----------------------------------------------------//
//-- Uncomment whichever data line you want to use --//
//------- First line is already uncommented --------//
//-------------------------------------------------//

//-- Guild APIs --//
$json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/guild/'.$RealmName.'/'.$GuildName.'?locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/guild/'.$RealmName.'/'.$GuildName.'?fields=achievements&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/guild/'.$RealmName.'/'.$GuildName.'?fields=challenge&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/guild/'.$RealmName.'/'.$GuildName.'?fields=members&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/guild/'.$RealmName.'/'.$GuildName.'?fields=news&locale='.$LocaleName.'&apikey='.$APIkey.'');

//-- Player APIs --//
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=achievements&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=appearance&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=audit&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=feed&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=guild&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=hunterPets&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=items&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=mounts&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=pets&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=petSlots&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=progression&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=pvp&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=quests&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=reputation&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=stats&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=talents&locale='.$LocaleName.'&apikey='.$APIkey.'');
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/character/'.$RealmName.'/'.$PlayerName.'?fields=titles&locale='.$LocaleName.'&apikey='.$APIkey.'');

//-- Realm APIs --//
//-- $json_wow_api_url = file_get_contents('https://'.$RegionName.'.api.battle.net/'.$GameName.'/realm/status?locale='.$LocaleName.'&apikey='.$APIkey.'');

//----------------------------------------------------------------//
//-- Output (to browser) whichever line you uncommented above. --//
//--------------------------------------------------------------//
echo '<h3>World of Warcraft - API Info</h3><pre>';
var_dump(json_decode($json_wow_api_url, true));
echo '</pre>';
?>
Sticky Request please.

EDIT: Thank you!
Update the coding and added a file for download. Written for PHP 5.
Im getting file not found when i try to go there, dead link possibly?
If your looking for a package to use T3ch, I've had good luck with Ulminia's blizzard-api-oauth client https://github.com/Ulminia/blizzard-api-oauth.

You can also find a list of other libraries you can use here: http://us.battle.net/en/forum/topic/14729973498
I hate to /rez an old post but, are there any samples like this that work with the latest API so I can begin learning how to use this stuff the right way.? I was going to attempt to work with this and then pour over the migration stuff I found, but it would be smoother if I could just find current working samples... thanks in advance. to be honest, I "learn" most of coding from a script kiddie style, by taking existing code and modifying it, so its helpfull to work with good stuff.. garbage in garbage out if you know what I mean

Join the Conversation

Return to Forum