-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathservice.php
More file actions
123 lines (112 loc) · 3.15 KB
/
service.php
File metadata and controls
123 lines (112 loc) · 3.15 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
class BlockIoServeice{
private $apiKey = ""; // YOUR API KEY FOR DOGECOIN, BITCOIN, OR LITECOIN
private $pin = ""; // YOUR SECRET PIN
private $version = "2"; // the API version to use
public function __construct(){
if(empty($this->apiKey) || empty($this->pin) || empty($this->version)){
try {
throw new Exception('apiKey, pin and version cannot be empty.');
} catch(Exception $e) {
echo $e->getMessage();
}
}
}
/**
* Main Curl Request
**/
private function cRequest($urlcomponent, $params = []){
$url = 'https://block.io/api/v'.$this->version.'/'.$urlcomponent.'?api_key='.$this->apiKey.'&pin='.$this->pin;
$curl = curl_init();
foreach($params as $param => $value){
if(is_array($value)){
$value = implode(',', $value);
}
$url .= '&' . $param . '=' . $value;
}
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_SSL_VERIFYPEER => false //for non ssl
));
$response = curl_exec($curl);
curl_close($curl);
//print_r(curl_error($ch));
return json_decode($response);
}
/**
* Address Related
**/
public function get_balance(){
return $this->cRequest('get_balance');
}
public function get_new_address($params = []){
return $this->cRequest('get_new_address', $params);
}
public function get_my_addresses(){
return $this->cRequest('get_my_addresses');
}
public function get_address_balance($params = []){
return $this->cRequest('get_address_balance', $params);
}
public function get_address_by_label($params){
return $this->cRequest('get_address_by_label', $params);
}
/**
* Withdrawal Related
**/
public function withdraw($params){
return $this->cRequest('withdraw', $params);
}
public function withdraw_from_addresses($params){
return $this->cRequest('withdraw_from_addresses', $params);
}
public function withdraw_from_labels($params){
return $this->cRequest('withdraw_from_labels', $params);
}
public function get_network_fee_estimate($params){
return $this->cRequest('get_network_fee_estimate', $params);
}
/**
* Archive Related
**/
public function archive_addresses($params){
return $this->cRequest('archive_addresses', $params);
}
public function unarchive_addresses($params){
return $this->cRequest('unarchive_addresses', $params);
}
public function get_my_archived_addresses($params){
return $this->cRequest('get_my_archived_addresses', $params);
}
/**
* Current price Related
**/
public function get_current_price($params = []){
return $this->cRequest('get_current_price', $params);
}
/**
* BlockIO Green address Related
**/
public function is_green_address($params){
return $this->cRequest('is_green_address', $params);
}
public function is_green_transaction($params){
return $this->cRequest('is_green_transaction', $params);
}
/**
* Transaction Related
**/
public function get_transactions($params){
return $this->cRequest('get_transactions', $params);
}
/**
* Webhook Related
**/
public function create_notification($params){
return $this->cRequest('create_notification', $params);
}
public function get_notifications($params){
return $this->cRequest('get_notifications', $params);
}
}