Post
Topic
Board Bitcoin Technical Support
Topic OP
Why this PHP code is not posting BTC price in USD on 29-08-2019?
by
CounterEntropy
on 29/08/2022, 17:23:09 UTC
Neither this...
Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.coingecko.com/api/v3/coins/bitcoin/history?date=29-08-2019&localization=false');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$object = json_decode($response);
$usdVal = $object->market_data->current_price->usd;
echo $usdVal;

Nor this...
Code:
ini_set('max_execution_time', 300);
$url ='https://api.coingecko.com/api/v3/coins/bitcoin/history?date=29-08-2019&localization=false';
$data = file_get_contents($url);
$object = json_decode($data);
$usdVal = $object->market_data->current_price->usd;
echo $usdVal;

What am I doing wrong?