/** * runs through all api keys registered, testing them for validity, * will up failcount if failed * @param array $options * @return void */ public function key_check(array $options) { $keys = Kingboard_EveApiKey::find(); foreach ($keys as $key) { $this->cli->message("testing {$key['userid']}"); $pheal = new Pheal($key['userid'], $key['apikey']); try { $pheal->Characters(); $this->cli->positive('ok'); } catch (PhealApiException $e) { $this->cli->error('failed'); if (!isset($key['failed'])) { $key->failed = 0; } $key->failed++; $key->save(); } } }
public function api_import(array $options) { $this->cli->message("import running"); $newkills = 0; $oldkills = 0; $errors = 0; $keys = Kingboard_EveApiKey::find(); foreach ($keys as $key) { $pheal = new Pheal($key['userid'], $key['apikey']); $pheal->scope = "account"; try { foreach ($pheal->Characters()->characters as $char) { try { $this->cli->message('trying corp import on ' . $char->name . "..."); $pheal->scope = 'corp'; $kills = $pheal->Killlog(array('characterID' => $char->characterID))->kills; } catch (PhealAPIException $e) { $this->cli->message('corp failed, trying char import now..'); $pheal->scope = 'char'; try { $kills = $pheal->Killlog(array('characterID' => $char->characterID))->kills; } catch (PhealAPIException $e) { continue; } } $this->cli->message("fetch done, parsing now"); $kakp = new Kingboard_ApiKillParser(); $info = $kakp->parseKills($kills); $oldkills += $info['oldkills']; $newkills += $info['newkills']; $errors += $info['errors']; } } catch (PhealApiException $e) { if (!isset($key['failed'])) { $key->failed = 0; } $key->failed++; $key->save(); } catch (PhealException $pe) { $this->cli->message("PhealException caught, auch!"); continue; } } $totalkills = $oldkills + $newkills; $this->cli->message("found {$totalkills} kills, {$oldkills} where allready in database, {$newkills} added ( errors: {$errors})"); }