Author

Topic: Blocktrail API Web Hooks Help (Read 281 times)

newbie
Activity: 2
Merit: 0
February 15, 2017, 07: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:


$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);

?>
Jump to: