I have been using the following code to retrieve stock data from Yahoo for over a year now:
$live = "http://download.finance.yahoo.com/d/quotes.csv?s=" . $_GET["code"] . "&f=sb2m3m7et8n4e7e8e9ia2";
$file=fopen($live,"r") or exit("Unable to open file!");
while(!feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
Just recently it has stopped working. I first noticed it on a WordPress Widget I wrote. The only error it gives me is a timeout error. If I leave it to timeout then it obviously suspends my account (which gets annoying after a while). I've been using this code in many PHP Stock Data projects and they have all stopped working! Strangely if you paste the constructed $live string directly as a URL then it works fine. It just shows the data in the web browser as expected. But not in PHP! I've tried using the PHP "file" command to read the constructed URL into an array but it produces the same error.
I'm I doing something wrong? Help would be appreciated.
If you'd like a $_GET["code"] variable to test then try 'LLOY.L'
Many thanks,
Jason.
$live = "http://download.finance.yahoo.com/d/quotes.csv?s=" . $_GET["code"] . "&f=sb2m3m7et8n4e7e8e9ia2";
$file=fopen($live,"r") or exit("Unable to open file!");
while(!feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
Just recently it has stopped working. I first noticed it on a WordPress Widget I wrote. The only error it gives me is a timeout error. If I leave it to timeout then it obviously suspends my account (which gets annoying after a while). I've been using this code in many PHP Stock Data projects and they have all stopped working! Strangely if you paste the constructed $live string directly as a URL then it works fine. It just shows the data in the web browser as expected. But not in PHP! I've tried using the PHP "file" command to read the constructed URL into an array but it produces the same error.
I'm I doing something wrong? Help would be appreciated.
If you'd like a $_GET["code"] variable to test then try 'LLOY.L'
Many thanks,
Jason.