Answer the question
In order to leave comments, you need to log in
Error when requesting PHP api?
The problem is that when you do concatenation in this line, the code stops working:
$url = 'https://api.coindesk.com/v1/bpi/historical/close.json?start='.$today_minus_god .'&end=2018-08-20';
Warning: file_get_contents(https://api.coindesk.com/v1/bpi/historical/close.json?start=2017-20-08&end=2018-08-20): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\wp2.com\wp-content\themes\twentyfifteen\page-15.php on line 40
$today = date("Y-d-m");
$minus_god_microtime = getdate(mktime(0, 0, 0, date('m'), date('d'), date('Y') - 1 ));
$today_minus_god = date("Y-d-m", $minus_god_microtime[0]);
$url = 'https://api.coindesk.com/v1/bpi/historical/close.json?start=2017-08-20&end=2018-08-20';
$json = file_get_contents($url);
$json = json_decode($json, true);
print_r($json);
Answer the question
In order to leave comments, you need to log in
Have you tried opening it in a browser? It even writes an error there.
Does anything bother you about the date?
?start=2017-20-08&end=2018-08-20
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question