1. Go to this page and download the library: Download cointokenhub/cmc-api-php 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/ */
cointokenhub / cmc-api-php example snippets
use GuzzleHttp\Client;
use CoinTokenHub\CoinMarketCapApi\CoinMarketCap;
$httpClient = new Client();
$cmcApi = new CoinMarketCap($httpClient);
$api->ticker('AUD', false, 5);
$api->currencyTicker($coin);
$api->globalData();
namespace App\Http\Controllers;
use GuzzleHttp\Client;
use CoinTokenHub\CoinMarketCapApi\CoinMarketCap;
class CoinController extends Controller
{
private $httpClient;
public function __construct(Client $httpClient) {
$this->httpClient = $httpClient;
}
public function coin($coin) {
$api = new CoinMarketCap($this->httpClient);
return json_encode($api->currencyTicker($coin));
}
public function ticker() {
$api = new CoinMarketCap($this->httpClient);
return json_encode($api->ticker('AUD', false, 5));
}
public function globalData() {
$api = new CoinMarketCap($this->httpClient);
return json_encode($api->globalData());
}
}
'providers' => [
// Other service providers...
CoinTokenHub\CoinMarketCapApi\CoinMarketCapServiceProvider::class,
],