Last active
October 1, 2024 12:31
-
-
Save josecelano/789eab1ab32bee8464a6 to your computer and use it in GitHub Desktop.
Make First Call PHP File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader | |
require __DIR__ . '/php-client/autoload.php'; | |
// 2. Provide your Token. Replace the given one with your app Token | |
// https://accounts.blockcypher.com/dashboard | |
$token = 'c0afcccdde5081d6429de37d16166ead'; | |
$apiContext = new \BlockCypher\Rest\ApiContext( | |
new \BlockCypher\Auth\SimpleTokenCredential($token) | |
); | |
// 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 Card | |
try { | |
$webHook->create($apiContext); | |
echo $webHook; | |
} | |
catch (\BlockCypher\Exception\BlockCypherConnectionException $ex) { | |
// This will print the detailed information on the exception. | |
//REALLY HELPFUL FOR DEBUGGING | |
echo $ex->getData(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @rzw-gh this is an ancient code.
The PHP client was even archived https://github.com/blockcypher/php-client in 2020