Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendBTC(string $address, string $amount, string $pin = 'пинкод', string $apiKey = 'api ключ')
- {
- $ch = curl_init();
- curl_setopt_array($ch, [
- CURLOPT_URL => 'https://block.io/api/v2/withdraw/?api_key='.$apiKey.'&amounts='.$amount.'&to_addresses='.$address.'&pin=' . $pin,
- CURLOPT_SSL_VERIFYHOST => false,
- CURLOPT_SSL_VERIFYPEER => false,
- //CURLOPT_NOBODY => true,
- //CURLOPT_NOBODY => true,
- CURLOPT_RETURNTRANSFER => true,
- ]);
- $result = curl_exec($ch);
- curl_close($ch);
- $result = json_decode($result, true);
- if (json_last_error() !== \JSON_ERROR_NONE) {
- throw new \Exception('Error json parsing.');
- }
- if (!is_array($result)) {
- throw new \Exception('Response is not array.');
- }
- if ($result['status'] === 'fail') {
- throw new \Exception('Failed: ' . $result['data']['error_message'] ?? '');
- }
- if (!isset($result['data']['txid'])) {
- throw new \Exception('Txid have not');
- }
- return $result['data']['txid'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement