Skip to content

Instantly share code, notes, and snippets.

@josecelano
Last active August 29, 2015 14:20
Show Gist options
  • Save josecelano/b84c2d2dcb6e1f750ba8 to your computer and use it in GitHub Desktop.
Save josecelano/b84c2d2dcb6e1f750ba8 to your computer and use it in GitHub Desktop.
Adding SDK Configurations to enable Logging
<?php
// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader
//require __DIR__ . '/php-client/autoload.php'; // Direct Donwload
require __DIR__ . '/vendor/autoload.php'; // Using Composer
// 2. Provide your Token. Replace the given one with your token
// https://accounts.blockcypher.com/dashboard
$token = 'c0afcccdde5081d6429de37d16166ead';
$apiContext = new \BlockCypher\Rest\ApiContext(
new \BlockCypher\Auth\SimpleTokenCredential($token)
);
// Step 2.1 : Between Step 2 and Step 3
$apiContext->setConfig(
array(
'mode' => 'sandbox',
'log.LogEnabled' => true,
'log.FileName' => 'BlockCypher.log',
'log.LogLevel' => 'DEBUG'
)
);
// 3. Lets try to create a new webhook using WebHook API mentioned here
// http://dev.blockcypher.com/#webhooks
$webHook = new \BlockCypher\Api\WebHook();
$webHook->setUrl("https://requestb.in/slmm49sl?uniqid=" . uniqid());
$webHook->setEvent('unconfirmed-tx');
// 4. Make a Create Call and Print the WebHook
try {
$webHook->create($apiContext);
echo $webHook;
}
catch (\BlockCypher\Exception\BlockCypherConnectionException $ex) {
echo $ex;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment