Pheal\Pheal::detectAccess PHP Method

detectAccess() public method

Keep in mind this method will make an api request to account/APIKeyInfo based on the given \Pheal\Core\Config settings with the given key credentials. More important! This method will throw Exceptions on invalid keys or networks errors So place this call into your try statement
public detectAccess ( ) : boolean | Pheal\Core\Result
return boolean | Pheal\Core\Result
    public function detectAccess()
    {
        // don't request keyinfo if api keys are not set or if new CAK aren't enabled
        if (!$this->userid || !$this->key || !Config::getInstance()->api_customkeys) {
            return false;
        }
        // request api key info, save old scope and restore it afterwords
        $old = $this->scope;
        $this->scope = "account";
        $keyinfo = $this->APIKeyInfo();
        $this->scope = $old;
        // set detected keytype and accessMask
        $this->setAccess($keyinfo->key->type, $keyinfo->key->accessMask);
        // return the APIKeyInfo Result object in the case you need it.
        return $keyinfo;
    }

Usage Example

Example #1
0
 /**
  * fetch all kills for $key
  * @static
  * @param array $key
  * @return array
  */
 public static function fetch($key)
 {
     $newkills = 0;
     $oldkills = 0;
     $errors = 0;
     $pheal = new Pheal($key['apiuserid'], $key['apikey']);
     $pheal->detectAccess();
     $characters = $pheal->accountScope->Characters()->characters;
     foreach ($characters as $character) {
         switch ($key['type']) {
             case "Corporation":
                 $pheal->scope = "corp";
                 break;
             case "Account":
                 // account keys are like character keys, just for the complete account
             // account keys are like character keys, just for the complete account
             case "Character":
                 $pheal->scope = "char";
                 break;
             default:
                 // not a key type we can use..
                 continue;
         }
         $kills = $pheal->Killlog(array('characterID' => $character->characterID))->kills;
         $kakp = new \Kingboard\Lib\Parser\EveAPI();
         $info = $kakp->parseKills($kills);
         $oldkills += $info['oldkills'];
         $newkills += $info['newkills'];
         $errors += $info['errors'];
     }
     return array("old" => $oldkills, "new" => $newkills, "total" => $oldkills + $newkills, "errors" => $errors);
 }
All Usage Examples Of Pheal\Pheal::detectAccess