API: field "guild" is missing

API Discussion
Hello I am writing a guild management tool. It have to detect if a character has left the guild, so it can be removed from the guildroaster. But unfortunately it seems that the battle.net API does not always return the guild field.

I am using this code:

$url = bnetAPI::buildURL('character', 'wow', [
'char' => $this->charname,
'realm' => $this->realmname
],
['guild', 'items', 'feed']);
$request = new HTTPRequest($url);
try {
$request->execute();
}
catch (HTTPNotFoundException $e) {
[...]
}
$reply = $request->getReply();
$charData=JSON::decode($reply['body'], true);
[...]
if (isset($charData['guild']['name']) && $charData['guild']['name'] == GMAN_MAIN_GUILDNAME) {
$charData['inGuild'] = 1;
}
else {
$charData['inGuild'] = 0;
}
[...]
$sql = "UPDATE wcf".WCF_N."_gman_wow_character
SET inGuild = ?
WHERE charID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute([
$charData['inGuild'],
$charID
]);


It happens in 3 of 400 cases.

correct:
https://eu.api.battle.net/wow/character/Forscherliga/Coldron?locale=de_DE&fields=guild,items,feed,&apikey=xxx

wrong:
https://eu.api.battle.net/wow/character/Forscherliga/Jendial?locale=de_DE&fields=guild,items,feed,&apikey=xxx

These two chars are my alts, and yes I am sure that both are in my guidl. I recently logged into the game to check.

Images:
http://imgur.com/a/GhSB1

Join the Conversation

Return to Forum