$apikey, 'signature' => $sign, 'nonce' => $nonce ); if (!empty($params)) { foreach($params as $k=>$v) $postdata[$k] = $v; } $post_data = http_build_query($postdata, '', '&'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); //curl_setopt($ch, CURLOPT_SSLVERSION, 1 /*CURL_SSLVERSION_TLSv1*/); curl_setopt($ch, CURLOPT_SSL_SESSIONID_CACHE, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; cex.io API PHP client; '.php_uname('s').'; PHP/'.phpversion().')'); curl_setopt($ch, CURLOPT_ENCODING , ''); $execResult = curl_exec($ch); $res = json_decode($execResult, true); return $res; } // https://cex.io/rest-api#ticker function cexio_btceur() { $ticker = cexio_api_query('ticker', 'BTC/EUR'); return is_array($ticker) ? floatval($ticker["last"]) : false; } function cexio_btcusd() { $ticker = cexio_api_query('ticker', 'BTC/USD'); return is_array($ticker) ? floatval($ticker["last"]) : false; } // https://cex.io/rest-api#account-balance function getCexIoBalances() { $exchange = 'cexio'; if (exchange_get($exchange, 'disabled')) return; $savebalance = getdbosql('db_balances', "name='$exchange'"); if (is_object($savebalance)) { $balances = cexio_api_user('balance'); if (is_array($balances)) { $b = arraySafeVal($balances, 'BTC'); $savebalance->balance = arraySafeVal($b, 'available'); $savebalance->save(); } } }