PHP code example of shahradelahi / coindesk-ticker

1. Go to this page and download the library: Download shahradelahi/coindesk-ticker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shahradelahi / coindesk-ticker example snippets



$CDApi = new CoinDesk\Api();

$Settings = [
    'close_time' => strtotime('+30 minute', time()) // Required
];

$CDApi->ticker()->setTicker(function (array $Tick) {

    // Print out the ticks
    echo "<pre>" . json_encode($Tick, JSON_PRETTY_PRINT) . "</pre>"; 
    
}, $Settings);

$OneTick = $CDApi->ticker()->getOneTick();
echo "<pre>" . json_encode($OneTick, JSON_PRETTY_PRINT) . "</pre>";

$CurrentPrice = $CDApi->getCurrentPrice();
echo "<pre>" . json_encode($CurrentPrice, JSON_PRETTY_PRINT) . "</pre>";

sudo apt-get install curl php-curl
curl -s http://getcomposer.org/installer | php
php composer.phar install

php composer.phar