API
Версия от 17:14, 23 февраля 2020; User3 (обсуждение | вклад) (Новая страница: «<code> $KEY_50x = 'INSERT API KEY HERE'; $SEC_50x = 'INSERT API SEC HERE'; function api_call_50x($method, $pars, $api_key, $api_sec) { $URL_50x = 'https://a...»)
$KEY_50x = 'INSERT API KEY HERE';
$SEC_50x = 'INSERT API SEC HERE';
function api_call_50x($method, $pars, $api_key, $api_sec) {
$URL_50x = 'https://api.50x.com/';
$pars = json_decode($pars, true);
$pars['timestamp'] = number_format(microtime(true)*1000, 0, '.', );
$query_string = http_build_query($pars, , '&');
$sign = $m = hash_hmac('sha256', $query_string, $api_sec);
$pars['signature'] = $sign;
$query_string = http_build_query($pars, , '&');
$header = array(
"Content-Type: application/x-www-form-urlencoded",
"Accept': 'application/json",
"User-Agent: 50x/php",
"X-MBX-APIKEY: $api_key",
"ORIGIN-PARS: $query_string"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL_50x.$method.'/');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($pars));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$json = api_call_50x('json.userinfo', '{}', $KEY_50x, $SEC_50x);
//$json = api_call_50x('json.place_order', '{"pair":"XRP/A2A","v":45.02643798,"ot":"l","r":8.4,"bs":"s"}', $KEY_50x, $SEC_50x);
//$json = api_call_50x('json.orderslist', '{"pn":1}', $KEY_50x, $SEC_50x);
//$json = api_call_50x('json.blotter', '{"sym":"ETH"}', $KEY_50x, $SEC_50x);
echo "
";
echo json_encode(json_decode($json), JSON_PRETTY_PRINT);
echo "
";