· 7 years ago · Feb 22, 2018, 04:30 PM
1<?php
2$secret_key = "xxx";
3$access_key = "xxx";
4// $nonce = time() ; //*1000; //***
5 $nonce = round(microtime(true) * 1000); /* this works! */
6// $nonce = round(microtime(true)*100).round(microtime(true)*100); //***
7$username = "DecardCoin";
8$message = $nonce.$username.$access_key;
9$signature = hash_hmac('sha256',$message,$secret_key);
10 echo $signature; echo '<br/><br/>'; //*** аутентификациÑ
11
12$url = 'https://www.hashnest.com/api/v1/currency_accounts';
13$params = array(
14'access_key' => $access_key,
15'nonce' => $nonce,
16'signature' => $signature );
17
18function getdata($url,$params = array()) { //*** Ñменил Ð¸Ð¼Ñ (curl_out) на (getdata) функции Ð´Ð»Ñ Ð½Ð°Ð³Ð»ÑдноÑти */
19 $ch = curl_init($url); /* что? где?
20 curl_setopt($ch, CURLOPT_POST, 1); /* как передаем (в каком виде)?
21 # CURLOPT_POST - TRUE Ð´Ð»Ñ Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ Ð¾Ð±Ñ‹Ñ‡Ð½Ð¾Ð³Ð¾ HTTP POST. Данный метод
22 # POST иÑпользует обычный application/x-www-form-urlencoded, обычно
23 # иÑпользуемый в HTML-формах. */
24
25
26 curl_setopt($ch, CURLOPT_POSTFIELDS, $params); /* что передаем? - Ð’Ñе данные, передаваемые в HTTP POST-запроÑе. */
27 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //*?*//
28 # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
29 # not to print out the results of its query.
30 # Instead, it will return the results as a string return value
31 # from curl_exec() instead of the usual true/false.
32 $r = curl_exec($ch);
33 curl_close($ch);
34 echo $r; /* РЕЗУЛЬТÐТЫ ТУТ в $r */
35 }
36$result = getdata($url,$params);
37var_dump($result);
38
39/*$crncy1 = var_dump($result->currency);
40echo $crncy1;
41*/
42
43 echo '<br/><br/>nonce is: '; //***
44 echo $nonce; //***