2011-11-17 63 views
0

我试着去开始一个API合作调用信息的几位API实现

它的文档是很scarse和支持是相当渺茫但它是在它的方式相当不错

香港专业教育学院最近才开始了解阵列位然而等即时通讯也不太清楚,如果这将是对这个具体问题,我的障碍

的API IM挣扎的一个部分是这样的:

// Get the character object. Will return FALSE if the 
// character could not be found or character is frozen. 
$character = $armory->getCharacter('xxxx'); 

现在即时通讯相当停留在如何找到如果“假”

这是从类文件,如果它的任何帮助,你们的摘录:

  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; 
} 

https://sourceforge.net/p/wowarmoryapi/home/是API如果哪希望看到完整的API或命令列表

感谢

回答

0
if ($character->isValid() === false) { 
    //your code that runs if there is no character 
} 
else { 
    //your code that runs if everything is fine 
} 
+0

原因downvote? – kapa

+0

另一个论坛上,他们给了我下面的 “如果($字符= $ armory-> getCharacter($ CHARNAME)){// 字符被发现 }其他{未找到 //字符...重定向 }“ 这可能只是一个等待开发者的例子,因为这看起来似乎没有工作 – Ferryboi

+0

该版本似乎也没有问题。问题可能在代码中的其他地方。 – kapa

0
if ($character) { 
    // true stuff 
} else { 
    // false stuff 
} 

件许多事情评估为逻辑“假”在PHP: 数字值0, 空字符串, 未定义/未初始化的变量 空数组等等,等等