Skip to content

Instantly share code, notes, and snippets.

@josecelano
Last active October 20, 2019 17:45
Show Gist options
  • Save josecelano/789eab1ab32bee8464a6 to your computer and use it in GitHub Desktop.
Save josecelano/789eab1ab32bee8464a6 to your computer and use it in GitHub Desktop.
Make First Call PHP File
<?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();
}
@AbaddonRoma
Copy link

Warning: sizeof(): Parameter must be an array or an object that implements Countable in C:\FILES\XAMPP\htdocs\project\php-client\blockcypher\php-client\lib\BlockCypher\Common\BlockCypherModel.php on line 315

Warning: sizeof(): Parameter must be an array or an object that implements Countable in C:\FILES\XAMPP\htdocs\project\php-client\blockcypher\php-client\lib\BlockCypher\Common\BlockCypherModel.php on line 315
{"error": "API calls limits have been reached. To extend your limits please upgrade your plan on BlockCypher accounts page."}

@AbaddonRoma
Copy link

Who knows how to fix it please?

@ramkumarsri
Copy link

ramkumarsri commented Feb 2, 2018

Just put "@" symbol before sizeof() to hide these warning messages

@ptcrank
Copy link

ptcrank commented Oct 20, 2019

Move the first and second conditions

From
} else if (sizeof($v) <= 0 && is_array($v)) {

to the
} else if (is_array($v) && sizeof($v) <= 0) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment