반응형
<?php
$api_key = 'YOUR_API_KEY';
$api_secret = 'YOUR_API_SECRET';
$coinbase_url = 'https://api.coinbase.com/v2/accounts/YOUR_ACCOUNT_ID/transactions';
$data = array(
'type' => 'send',
'to' => 'RECIPIENT_ADDRESS',
'amount' => '0.1', // 보낼 비트코인의 양
'currency' => 'BTC'
);
$data_string = json_encode($data);
$ch = curl_init($coinbase_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'CB-ACCESS-KEY: ' . $api_key,
'CB-ACCESS-SIGN: ' . hash_hmac('sha256', $coinbase_url . $data_string, $api_secret),
'CB-ACCESS-TIMESTAMP: ' . time(),
'CB-VERSION: 2018-05-15'
));
$result = curl_exec($ch);
curl_close($ch);
$response = json_decode($result, true);
if ($response['data']['status'] == 'completed') {
echo '비트코인 전송이 완료되었습니다.';
} else {
echo '비트코인 전송이 실패하였습니다.';
}
?>
반응형
'DEVEL > PHP' 카테고리의 다른 글
PHP ChatGPT API 예제 (0) | 2023.07.20 |
---|---|
PHP Bitcoin Core - 비트코인(BTC) 전송 (0) | 2023.07.06 |
PHP Google 인증 토큰 유효성 체크 (0) | 2023.04.11 |
PHP 유튜브 채널 구독하기 (0) | 2023.03.16 |
PHP CURL POST 요청하기 (0) | 2023.03.15 |