Skip to content

WowColdFusionAPI is a ColdFusion Component that acts as a wrapper to the World of Warcraft Community Platform API

Notifications You must be signed in to change notification settings

Hanzo55/WoWColdFusionAPI

Repository files navigation

-- WoWColdFusionAPI --

Hey! This is a ColdFusion Component (CFC) which acts as a wrapper to the new World of Warcraft Community Platform API.

More to come! Cleanup incoming.

USAGE:

<cfscript>
// INIT (Region is US by default)
wow = CreateObject('component','com.blizzard.services.wow').init(cache=application.cache);

// uncomment the line below to use your Blizzard Application ID (supply the publicKey and privateKey they give you)
//wow = CreateObject('component','com.blizzard.services.wow').init(cache=application.cache,region='us',publicKey='XXXX',privateKey='YYYY');

// example of an INIT as Europe
//wow_eu = CreateObject('component','com.blizzard.services.wow').init(cache=application.cache, region='eu');

// example of changing the region after init
//wow.setRegion('eu');

// Get all realms
wowquery = wow.getRealms();

// Make sure there's no comm. error
if (!wowquery.error) {

	// Show me the status of Deathwing-US
	WriteOutput('Deathwing-US is up: ' & wowquery.realms.deathwing.status & '<br/>' ); 
	
	// **NOTE**: from here on out, we'll assume additional queries do not error out; remember that every call to getXXX() can potentially fail due to communication error, etc.
	// so be sure to check the 'error' key on the returned result. *PS Communication errors are offset a bit by the cache.
	
	// Output the realms in JSON format (we'll use an HTML textarea for convenience)
	WriteOutput('<textarea rows="40" cols="80">' & SerializeJSON(wowquery.realms) & '</textarea><br/>');	

	// Get a custom list of realms
	my = wow.getRealms(name='Deathwing,Aerie Peak,Cho''gall'); // you use two single quotes to 'escape' a single quote in CF; doubling the char. is a typical escape sequence
	
	// Get a character
	a = wow.getCharacter(realm='Deathwing', name='Mature', guild=true); // for this call, name means the name of the player, so we use 'realm' to designate the server

	//WriteOutput('My character''s guild is: ' & a.character.guild.name & ' on ' & a.character.guild.realm & '<br/>');

	// Get a Guild
	some = wow.getGuild(realm='Deathwing',name='Descendants of Draenor',members=true,achievements=true);
	WriteOutput('The guild: ' & some.guild.name & ' has ' & ArrayLen(some.guild.members) & ' members in it.<br/>');
	// You can even gain access to the colors of the guild's tabard
	WriteOutput('<table border="1" borderColor="' & Right(some.guild.emblem.borderColor,6) & '"><tr><td bgcolor="' & Right(some.guild.emblem.backgroundColor,6) & '"><font color="' & Right(some.guild.emblem.iconColor,6) & '">ICON</font></td></table><br/>');
	
	// Get an Auction House dataset
	// These are expensive requests, but know that they are cached both on Blizzard's site, via regular json data dumps, and on the WoWColdFusionAPI side, in the cache storage.
	auctionhouse = wow.getAuctionHouse(realm='Deathwing');

	// Get a specific item (my favorite below)
	item = wow.getItem(49623);
	WriteOutput('the favorite item of the day is: ' & item.name & '<br/>');

	// Here are some misc. utility queries Blizzard provided. Uncomment them if you want to try them out!
	//races = wow.getCharacterRaces();
	//classes = wow.getCharacterClasses();
	//gr = wow.getGuildRewards();
	//gp = wow.getGuildPerks();

// Some kind of error happened, show it
} else {

	WriteOutput('Some sort of error occurred. ' & wowquery.response);
}
</cfscript>

<!--- hey! don't forget about the custom realms you requested! --->
<cfif NOT wowquery.error>

	<!--- uncomment these to look at all the data coming back. Uncommenting them all at once will take some time to render --->

	<!--- <cfdump var=#wowquery#> ---> <!--- the first query we made, asking for all realms --->
	
	<!--- <cfdump var=#my#> ---> <!--- custom realms --->
	
	<!--- <cfdump var=#a#> ---> <!--- the character request --->
	
	<!--- <cfdump var=#some#> ---> <!--- the guild request --->

	<!--- <cfdump var="#auctionHouse#" top="10"> ---> <!--- the AH dump (just show the first 10 auctions for each house, otherwise the dump will timeout) --->
	
	<!--- <cfdump var="#item#"> ---> <!--- the favorite item --->
	
	<!--- 
	<cfdump var=#races# />
	<cfdump var=#classes# />
	<cfdump var=#gr# />
	<cfdump var=#gp# />
	 --->	
	
	<!--- for access to the cache, call this method below --->
	<!--- <cfdump var=#wow.dumpCache()#> --->	
</cfif>

Email me at shawn.a.holmes@gmail.com
[[ Hanzo - "Mature" on Deathwing-US ]]

About

WowColdFusionAPI is a ColdFusion Component that acts as a wrapper to the World of Warcraft Community Platform API

Resources

Stars

Watchers

Forks

Packages

No packages published