Bitcoin Forum
August 22, 2024, 09:23:56 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: Blocktrail API Web Hooks Help  (Read 277 times)
intelecticis (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!