Efficient character exists check

#1 - Nov. 27, 2012, 9:12 p.m.
Blizzard Post
I'm working with PHP and I want to be able to efficiently check if a character exists within Battle.net's armory. (Meaning, the armory data is available, isn't level sub-10, etc.)

Currently, this is how my quick-n-dirty check works:

$url = 'http://'.$region.'.battle.net/api/wow/character/'.$realm.'/'.$member['name'].'?fields= ';
$json = file_get_contents($url);
if ($json !== FALSE){
$decoded = json_decode($json);
if ($decoded !== FALSE || $decoded !== NULL){
/* Add player to Database */
return TRUE;
}


Is there a better way? I really hate pulling all that data needlessly.
Forum Avatar
Battle.net Developer
#4 - Nov. 28, 2012, 10:07 p.m.
Blizzard Post
The possibility that we could do (no promises on timeline) is get a new character resource api that basically returns the same data you get as part of the guild?fields=members api. It's heavily cached character data that just gives spec / class / level info etc. It would be cheaper than the full profile API on your limits and might provide slightly out of date info but might be better for many uses.

Of course for guild websites that only need this data fields=members is the cheapest way to get it already.
Forum Avatar
Battle.net Developer
#6 - Nov. 28, 2012, 10:24 p.m.
Blizzard Post
The possibility that we could do (no promises on timeline) is get a new character resource api that basically returns the same data you get as part of the guild?fields=members api. It's heavily cached character data that just gives spec / class / level info etc. It would be cheaper than the full profile API on your limits and might provide slightly out of date info but might be better for many uses.

Of course for guild websites that only need this data fields=members is the cheapest way to get it already.


That would be interesting, but I'm writing an application that is guild agnostic. Is there was a resource that could be called like player?fields=exists and returns some indication that the character exists before other fields get calls. Maybe it returns only character's name, or some other arbitrary data, just so long as it'd be differentiable from a DNE.


Sorry for any confusion, that's exactly what I meant. The new resource wouldn't be in the context of a guild, it would be the same DATA as you get as part of fields=members.

That being said, the api isn't supposed to be used to check this. Checking if a character you know about exists is ok, randomly checking names to find what characters exist is not. We do keep an eye out for apps that scan for profiles (on wow and d3).