I'm trying to create a widget which produces real-time data from popular cryptocurrencies. What I need is the symbol, name, price, and percent change in 24hours from 10 of the biggest gainers and 10 of the biggest losers in coins.
I'm using coinmarketcap's API documentation.
My code thus far is,
$API_KEY = "https://api.coinmarketcap.com/v2/ticker/?start=0&limit=100&sort=rank";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_KEY);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
$result = json_decode($server_output);
$dataForAllDays = $result['data'];
$dataForSingleCoin = $dataForAllDays['1'];
echo $dataForSingleCoin['symbol']
and it's producing a blank page. This is my first time coding anything like this so any ideas, feedback, etc. is welcome!