-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
55 lines (45 loc) · 1.45 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
53
54
55
<?php
function createNewAddress($private_key, $api_key , $name , $URL, $account_id){
$json = new stdClass();
$json->method = "POST";
$json->path = "/v2/accounts/".$account_id."/addresses";
$json->secretapikey = $private_key;
$json->apikey = $api_key;
$body = new stdClass();
$body->name = $name;
$result = json_encode($json);
$body = json_encode($body);
$time= time();
$sign = $time.$json->method.$json->path.$body;
$hmac = hash_hmac("SHA256", $sign, $json->secretapikey);
$header = array(
"CB-ACCESS-KEY:".$api_key,
"CB-ACCESS-SIGN:".$hmac,
"CB-ACCESS-TIMESTAMP:".time(),
"CB-VERSION:2019-11-15",
"Content-Type:application/json"
);
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$account_id = '31535d53-xxxx'; //Coinbase Account ID
$private_key = 'Doadlrxxxx'; //Coinbase Private Key
$api_key = 'ysEZjxxxx'; //Coinbase API KEY
$name = '1798520510'; //User TgId to add balance
$currency = 'LTC'; //Crypto To Send
$url = "https://api.coinbase.com/v2/accounts/$account_id/addresses";
$result = createNewAddress(
$private_key,
$api_key,
$name,
$url,
$account_id
);
$finalResult = json_decode($result);
print_r("$currency : ".$finalResult->data->address);
?>