Jump to content

API Implementation


ferryboi

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/251300-api-implementation/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/251300-api-implementation/#findComment-1288881
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/251300-api-implementation/#findComment-1289252
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.