Im currently trying to get all the bitcoin prices from the last 30 days in a comma seperated string.
Im getting the price from coinbase api via https://api.coinbase.com/v2/prices/btc-eur/spot?date=11.03.2016 for example.
Now what I did is a for loop where it inserts every date of the last 30 days into the api link and gives me a long string with all prices. I would like to comma seperate each price in that string now.
Here the Code currently:
<?php
for($i=1; $i<=30; $i++)
{
$pricedates = date('Y-m-d', strtotime('-'.$i.' days',strtotime(date('Y-m-d'))));
//Coinbase API for Historical Rates
// Get data from Coinbase API
$url = "https://api.coinbase.com/v2/prices/btc-eur/spot?date=".$pricedates."";
$btcdata = @file_get_contents($url);
$btcdata = json_decode($btcdata, true);
$btcprice = $btcdata['data']['amount'];
}
?>
Sample data
{"data":{"amount":"661.45","currency":"EUR"},"warnings":[{"id":"missing_version","message":"Please supply API version (YYYY-MM-DD) as CB-VERSION header","url":"https://developers.coinbase.com/api#versioning"}]}