<?php
function api_query($method, array $req = array()) {
// Obtain API keys under settings.
$publickey = 'd3498a999932fae8e5f80fba1046dfea234bdd47';
$privatekey = '68a629e1fe9fd59f5e62d4c080c5e0d488ab19c07605ba408a26ff7703df3b3c3e74745fb546f978';
$req['method'] = $method;
$mt = explode(' ', microtime());
$req['nonce'] = $mt[1];
// generate the POST data string
$post_data = http_build_query($req, '', '&');
$sign = hash_hmac("sha512", $post_data, $privatekey);
// generate the extra headers
$headers = array(
'Sign: '.$sign,
'Key: '.$publickey,
);
// our curl handle (initialize if required)
static $ch = null;
if (is_null($ch)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Tux API PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
}
curl_setopt($ch, CURLOPT_URL, 'https://tuxexchange.com/api');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// run the query
$res = curl_exec($ch);
if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch));
$dec = json_decode($res, true);
if (!$dec) throw new Exception('Invalid data received, please make sure connection is working and requested API exists');
return $dec;
}
// get ticker data
$result = api_query("getticker");
// Get my withdraw history
$result = api_query("getmywithdrawhistory");
// Get mybalances
$result = api_query("getmybalances");
// Get mybalances
$result = api_query("getmyopenorders");
// buy/sell/cancel
$result = api_query("buy", array("coin" => "DOGE" ,"market" => "BTC", "amount" => "1", "price" => "0.00000038"));
$result = api_query("sell", array("coin" => "DOGE" ,"market" => "BTC", "amount" => "1", "price" => "0.00000038"));
// cancelorder
$result = api_query("cancelorder", array("id" => "1234123", "market" => "BTC"));
// Request a withdraw.
$result = api_query("withdraw", array("coin" => "DOGE","address" => "DM2DasYjU1RWePFSLHFJqFMBtHSWbKmHpR", "amount" => "300"));
>
- Output for 7.0.0 - 7.0.29, 7.1.0 - 7.1.16, 7.2.0 - 7.2.4
- Parse error: syntax error, unexpected '>', expecting end of file in /in/Oo2gi on line 67
Process exited with code 255. - Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30
- Parse error: syntax error, unexpected '>' in /in/Oo2gi on line 67
Process exited with code 255. - Output for 5.0.0 - 5.0.5
- Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/Oo2gi on line 3
Process exited with code 255. - Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected T_ARRAY, expecting '&' or T_VARIABLE or T_CONST in /in/Oo2gi on line 3
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE or T_CONST in /in/Oo2gi on line 3
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error, expecting `'&'' or `T_VARIABLE' or `T_CONST' in /in/Oo2gi on line 3
Process exited with code 255.
preferences:
287.07 ms | 1395 KiB | 255 Q