コード例 #1
0
 }
 $errorCode = (int) @$row['errorCode'];
 if ($errorCode == 0 || $errorCode == 221) {
     \Pheal\Core\Config::getInstance()->http_user_agent = "API Fetcher for https://{$baseAddr}";
     \Pheal\Core\Config::getInstance()->http_post = false;
     \Pheal\Core\Config::getInstance()->http_keepalive = true;
     // default 15 seconds
     \Pheal\Core\Config::getInstance()->http_keepalive = 10;
     // KeepAliveTimeout in seconds
     \Pheal\Core\Config::getInstance()->http_timeout = 30;
     \Pheal\Core\Config::getInstance()->api_customkeys = true;
     $pheal = new \Pheal\Pheal($keyID, $vCode);
     try {
         $apiKeyInfo = $pheal->ApiKeyInfo();
     } catch (Exception $ex) {
         $tqApis->remove($row);
         // Problem with api the key, remove it from rotation
         $errorCode = (int) $ex->getCode();
         if ($errorCode == 904) {
             Util::out("(apiProducer) 904'ed");
             exit;
         }
         if ($errorCode == 28) {
             Util::out('(apiProducer) API Server timeout');
             exit;
         }
         if ($errorCode != 221 && $debug) {
             Util::out("(apiProducer) Error Validating {$keyID}: " . $ex->getCode() . ' ' . $ex->getMessage());
         }
         $apis->update(['keyID' => $keyID, 'vCode' => $vCode], ['$set' => ['errorCode' => $errorCode]]);
         sleep(3);
コード例 #2
0
ファイル: 1.apiConsumer.php プロジェクト: a-tal/zKillboard
 $params = array();
 $params['characterID'] = $charID;
 $result = null;
 try {
     $result = $pheal->KillMails($params);
 } catch (Exception $ex) {
     $errorCode = $ex->getCode();
     if ($errorCode == 904) {
         Util::out("(apiConsumer) 904'ed...");
         exit;
     }
     if ($errorCode == 28) {
         Util::out('(apiConsumer) API Server timeout');
         exit;
     }
     $tqApiChars->remove($row);
     sleep(3);
     continue;
 }
 $nextCheck = $result->cached_until_unixtime;
 $tqApiChars->setTime($row, $nextCheck);
 $newMaxKillID = 0;
 foreach ($result->kills as $kill) {
     $killID = (int) $kill->killID;
     $newMaxKillID = (int) max($newMaxKillID, $killID);
     $json = json_encode($kill->toArray());
     $killmail = json_decode($json, true);
     $killmail['killID'] = (int) $killID;
     $victim = $killmail['victim'];
     $victimID = $victim['characterID'] == 0 ? 'None' : $victim['characterID'];
     $attackers = $killmail['attackers'];
コード例 #3
0
<?php

require_once '../init.php';
$timer = new Timer();
$queueWars = new RedisTimeQueue('tqWars', 9600);
$minute = date('i');
if ($minute == 30) {
    $allWars = $mdb->getCollection('information')->find(['type' => 'warID'], ['id' => 1]);
    foreach ($allWars as $war) {
        if (@$war['finished'] == 1) {
            $queueWars->remove($war['id']);
        } else {
            $queueWars->add($war['id']);
        }
    }
}
$added = 0;
while ($timer->stop() < 58000) {
    sleep(1);
    $id = $queueWars->next();
    if ($id == null) {
        exit;
    }
    $warRow = $mdb->findDoc('information', ['type' => 'warID', 'id' => $id]);
    if (@$warRow['timeFinished'] != null) {
        $threeDays = date('Y-m-d', time() - 86400 * 3);
        $warFinished = substr($warRow['timeFinished'], 0, 10);
        if ($warFinished <= $threeDays) {
            $mdb->set('information', ['type' => 'warID', 'id' => $id], ['finished' => true]);
            continue;
        }
コード例 #4
0
 \Pheal\Core\Config::getInstance()->http_post = false;
 \Pheal\Core\Config::getInstance()->http_keepalive = true;
 // default 15 seconds
 \Pheal\Core\Config::getInstance()->http_keepalive = 10;
 // KeepAliveTimeout in seconds
 \Pheal\Core\Config::getInstance()->http_timeout = 30;
 \Pheal\Core\Config::getInstance()->api_customkeys = true;
 $pheal = new \Pheal\Pheal($keyID, $vCode);
 try {
     $mdb->set('apis', $row, ['lastApiUpdate' => $mdb->now()]);
     $apiKeyInfo = $pheal->ApiKeyInfo();
     if ($errorCode != 0) {
         $mdb->set('apis', $row, ['errorCode' => 0]);
     }
 } catch (Exception $ex) {
     $tqApis->remove($id);
     // Problem with api the key, remove it from rotation
     $errorCode = (int) $ex->getCode();
     if ($errorCode == 904) {
         Util::out("(apiProducer) 904'ed");
         exit;
     }
     if ($errorCode == 28) {
         Util::out('(apiProducer) API Server timeout');
         exit;
     }
     if ($errorCode != 221 && $debug) {
         Util::out("(apiProducer) Error Validating {$keyID}: " . $ex->getCode() . ' ' . $ex->getMessage());
     }
     $apis->update(['keyID' => $keyID, 'vCode' => $vCode], ['$set' => ['errorCode' => $errorCode]]);
     sleep(3);