· 4 years ago · Nov 22, 2020, 02:34 PM
1<?php
2
3require __DIR__.'/vendor/autoload.php';
4
5use GuzzleHttp\Client;
6
7$public_key = 'XCM8KVkJrBxJqLLBQRExf1ex3xozhxS330MJy5G7';
8$secret_key = 'Fsly1kEuVLJAXWcVU4olkSvmiHAKm2S1Wv3WJZuD';
9
10
11$client = new Client([
12 'base_uri' => 'https://api.kuna.io',
13]);
14
15$api_path = '/v3/auth/me';
16
17$nonce = strval(date_timestamp_get(date_create()));
18//$nonce = time();
19$data = (object) [];
20
21$signatureString = $api_path.$nonce.json_encode($data);
22$signature = hash_hmac('sha384', $signatureString, $secret_key);
23
24$headers = [
25 // 'accept' => 'application/json',
26 // 'content-type' => 'application/json',
27 'kun-nonce' => $nonce,
28 'kun-apikey' => $public_key,
29 'kun-signature' => $signature,
30];
31$options = [
32 'form_params' => $data,
33 'headers' => $headers,
34 'http_errors' => false,
35 // 'debug' => true,
36];
37
38print_r($signatureString);
39echo PHP_EOL;
40print_r($options);
41echo PHP_EOL;
42
43$response = $client->request('POST', $api_path, $options);
44$result = $response->getBody()->getContents();
45print_r($result);
46echo PHP_EOL;