Bitcoin Forum
December 14, 2017, 06:45:01 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Blocktrail API Web Hooks Help  (Read 199 times)
intelecticis
Newbie
*
Offline Offline

Activity: 3


View Profile
February 15, 2017, 11:39:45 AM
 #1

Hello, friends.

I would like to ask you about Blocktrail API.

I want to using Web Hooks, but don't understand the API.

Can you write some short cURL PHP example how use it?

I would like to using cURL, because don't have composer to use PHP.

I would like to use 2 options:

https://www.blocktrail.com/api/docs/lang/curl#api_webhook_event_create

https://www.blocktrail.com/api/docs/lang/curl#api_webhook_event_delete

Thanks in advance!

PS

I just try this script, but something is wrong:

<?php

$service_url = 'https://api.blocktrail.com/v1/BTC/webhook/WEB_HOOK_ID/events?api_key=API_KEY';
$curl = curl_init($service_url);
$curl_post_data = array(
        'event_type' => 'address-transactions',
        'address' => '1NcXPMRaanz43b1kokpPuYDdk6GGDvxT2T',
        'confirmations' => 1,
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
if ($curl_response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('error occured during curl exec. Additioanl info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($curl_response);
if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') {
    die('error occured: ' . $decoded->response->errormessage);
}
echo 'response ok!';
var_export($decoded->response);

?>
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!