-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
52 lines (36 loc) · 1.35 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
echo "starting...\n ";
echo "and second line ";
date_default_timezone_set('Australia/Sydney');
echo 'Date: ' . date("D M d, Y G:i a") . '<br>';
$secret_key = "your private key";
$secret_key_encoded = base64_decode($secret_key);
$public_key = "your public key";
$milliseconds = round(microtime(true) * 1000);
$msg = "/account/balance\n" . $milliseconds . "\n";
echo "Message is:\n" . $msg;
$encodedMsg = hash_hmac('sha512', $msg, $secret_key_encoded, true);
$base64Msg = base64_encode($encodedMsg);
echo "Encoded Message is: \n" . $base64Msg . "<br>";
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=> "Accept: */*\r\n" .
"Accept-Charset: UTF-8\r\n" .
"Content-Type: application/json\r\n" .
"apikey: " . $public_key . "\r\n" .
"timestamp: " . $milliseconds . "\r\n" .
"User-Agent: btc markets php client\r\n" .
"signature: " . $base64Msg . "\r\n"
)
);
$context = stream_context_create($opts);
var_dump($opts);
// Open the file using the HTTP headers set above
$json = file_get_contents('https://api.btcmarkets.net/account/balance', false, $context);
var_dump($json);
?>