ferryboi Posted November 17, 2011 Share Posted November 17, 2011 Hey Guys, Im using an API to run a few calls and im not too experienced with them $character = $armory->getCharacter('bob'); // Character name This is the call it is making now apparently if the name bob doesnt exist then it is meant to provide a "FALSE" response but im just wondering how to check the response - when the name is correct everything displays as it should do What im aiming for is to get the following somehow $character = $armory->getCharacter('deathecus');// Character name If the name exists > continue on > if its false then redirect to a not found page Quote Link to comment https://forums.phpfreaks.com/topic/251300-api-implementation/ Share on other sites More sharing options...
gizmola Posted November 17, 2011 Share Posted November 17, 2011 if ($character = $armory->getCharacter($charname)) { // character was found } else { // character was not found... redirect } Quote Link to comment https://forums.phpfreaks.com/topic/251300-api-implementation/#findComment-1288878 Share on other sites More sharing options...
ferryboi Posted November 17, 2011 Author Share Posted November 17, 2011 Hmm Strange :/ I tried <? if ($character = $armory->getCharacter($charname)) { echo "The if statement evaluated to true"; } else { echo "The if statement evaluated to false"; }?> And no matter what character name i add in true or false it just keeps coming back with "The if statement evaluated to true" function __construct($region, $realm, $character, $ignoreFields = FALSE) { if ($ignoreFields != FALSE){ $this->excludeFields($ignoreFields); } $this->region = strtolower($region); $this->realm = $realm; $this->name = $character; $jsonConnect = new jsonConnect(); $this->characterData = $jsonConnect->getCharacter($character, $realm, $region, implode(",",$this->fields)); if ($this->characterData != FALSE){ $this->name = $this->characterData['name']; $this->setTitles(); $this->setTalentTreeSelected(); $this->race = new Races($region); $this->class = new Classes($region); } else { return FALSE; } return TRUE; } That seems to be the isolated section from the API class file , not sure if that will help at all Quote Link to comment https://forums.phpfreaks.com/topic/251300-api-implementation/#findComment-1288881 Share on other sites More sharing options...
gizmola Posted November 17, 2011 Share Posted November 17, 2011 Check to see what the value of $character is after you make the api call using var_dump($character); Quote Link to comment https://forums.phpfreaks.com/topic/251300-api-implementation/#findComment-1289059 Share on other sites More sharing options...
ignace Posted November 18, 2011 Share Posted November 18, 2011 I've delved into the code. <sarcasm>Thank you for providing a link BTW.</sarcasm> $character = $armory->getCharacter($charname) if ($character->isValid()) { // character was found } else { // character was not found... redirect } Try that. http://sourceforge.net/p/wowarmoryapi/home/Home/ -- WoW Armory API docs. Quote Link to comment https://forums.phpfreaks.com/topic/251300-api-implementation/#findComment-1289252 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.