stex: use new url of stocksexchange

This commit is contained in:
Tanguy Pruvot 2018-10-03 22:24:00 +02:00
parent 8ad60658e4
commit 685747b1b8

View file

@ -1,12 +1,11 @@
<?php <?php
// markets https://stocks.exchange/api2/markets // markets https://app.stex.com/api2/markets
// prices https://stocks.exchange/api2/ticker // prices https://app.stex.com/api2/ticker
// prices https://stocks.exchange/api2/prices (unused)
function stocksexchange_api_query($method) function stocksexchange_api_query($method)
{ {
$uri = "https://stocks.exchange/api2/$method"; $uri = "https://app.stex.com/api2/$method";
$ch = curl_init($uri); $ch = curl_init($uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@ -26,9 +25,10 @@ function stocksexchange_api_user($method, $params=array())
if (empty(EXCH_STOCKSEXCHANGE_KEY) || empty(EXCH_STOCKSEXCHANGE_SECRET)) return false; if (empty(EXCH_STOCKSEXCHANGE_KEY) || empty(EXCH_STOCKSEXCHANGE_SECRET)) return false;
$exchange = 'stocksexchange';
$mt = explode(' ', microtime()); $mt = explode(' ', microtime());
$nonce = $mt[1].substr($mt[0], 2, 6); $nonce = $mt[1].substr($mt[0], 2, 6);
$url = "https://stocks.exchange/api2?method=$method&nonce=$nonce"; $url = "https://app.stex.com/api2?method=$method&nonce=$nonce";
$sign_data = json_encode($params); $sign_data = json_encode($params);
$sign = hash_hmac('sha512', $sign_data, EXCH_STOCKSEXCHANGE_SECRET); $sign = hash_hmac('sha512', $sign_data, EXCH_STOCKSEXCHANGE_SECRET);
@ -57,7 +57,7 @@ function stocksexchange_api_user($method, $params=array())
$res = curl_exec($ch); $res = curl_exec($ch);
if($res === false) { if($res === false) {
$e = curl_error($ch); $e = curl_error($ch);
debuglog("stocksexchange: $e"); debuglog("$exchange: $e");
curl_close($ch); curl_close($ch);
return false; return false;
} }
@ -66,9 +66,9 @@ function stocksexchange_api_user($method, $params=array())
if(!is_object($result) && !is_array($result)) { if(!is_object($result) && !is_array($result)) {
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (strpos($res,'Maintenance')) if (strpos($res,'Maintenance'))
debuglog("stocksexchange: $method failed (Maintenance)"); debuglog("$exchange: $method failed (Maintenance)");
else else
debuglog("stocksexchange: $method failed ($status) ".strip_data($res)); debuglog("$exchange: $method failed ($status) ".strip_data($res));
} }
curl_close($ch); curl_close($ch);