I'm trying to access the historic data on Yahoo's api (with a PHP/Mysql implementation) using this url as an example:
$url = http://ichart.finance.yahoo.com/table.csv?s=INTC&c=2014&f=2015&a=0&d=0&b=1&e=1&g=d&ignore=.csv
This is the code I used to access it:
$filesize = 2000;
$handle = fopen($url, "r");
$raw_quote_data = fread($handle, $filesize);
echo $raw_quote_data;
fclose($handle);
The echo statement is for error checking, to make sure that I'm getting all the data before I store it in my database. However, the $raw_quote_data being returned only has data for the last 30 days of the time range inputted. Because the date range I inputted was from January 1, 2014 to January 1, 2015, it should return 365 days of data. So what am I doing wrong? Where is the rest of the data going?
The first thing I tried, of course, was changing the filesize, which has zero effect on the output.
Use file_get_contents()
instead.
$raw_quote_data = file_get_contents($url);