diff --git a/web/yaamp/commands/ExchangeCommand.php b/web/yaamp/commands/ExchangeCommand.php index eaadd69..30be31e 100644 --- a/web/yaamp/commands/ExchangeCommand.php +++ b/web/yaamp/commands/ExchangeCommand.php @@ -57,7 +57,8 @@ class ExchangeCommand extends CConsoleCommand if (!empty(EXCH_BITTREX_KEY)) { $balance = bittrex_api_query('account/getbalance','¤cy=BTC'); - echo("bittrex btc: ".json_encode($balance->result)."\n"); + if (!is_object($balance)) echo "bittrex error\n"; + else echo("bittrex btc: ".json_encode($balance->result)."\n"); } if (!empty(EXCH_BLEUTRADE_KEY)) { $balance = bleutrade_api_query('account/getbalances','¤cies=BTC'); @@ -66,7 +67,7 @@ class ExchangeCommand extends CConsoleCommand if (!empty(EXCH_BTER_KEY)) { $info = bter_api_user('getfunds'); if (!$info || arraySafeVal($info,'result') != 'true' || !isset($info['available_funds'])) echo "error\n"; - echo("bter available: ".json_encode($info['available_funds'])."\n"); + else echo("bter available: ".json_encode($info['available_funds'])."\n"); } if (!empty(EXCH_CCEX_KEY)) { $ccex = new CcexAPI; diff --git a/web/yaamp/core/exchange/kraken.php b/web/yaamp/core/exchange/kraken.php index d28d4e8..742ed41 100644 --- a/web/yaamp/core/exchange/kraken.php +++ b/web/yaamp/core/exchange/kraken.php @@ -86,6 +86,9 @@ class KrakenAPI curl_setopt($this->curl, CURLOPT_URL, $this->url . '/' . $this->version . '/public/' . $method); curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($this->curl, CURLOPT_HTTPHEADER, array()); + curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($this->curl, CURLOPT_TIMEOUT, 20); + $result = curl_exec($this->curl); if($result===false) throw new KrakenAPIException('CURL error: ' . curl_error($this->curl)); @@ -130,6 +133,9 @@ class KrakenAPI curl_setopt($this->curl, CURLOPT_URL, $this->url . $path); curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postdata); curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers); + curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($this->curl, CURLOPT_TIMEOUT, 20); + $result = curl_exec($this->curl); if($result===false) throw new KrakenAPIException('CURL error: ' . curl_error($this->curl));