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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.