Page 1 of 1

yahoo finance api

Posted: Sat Jan 16, 2010 5:13 pm
by jforce93
I want to access stock prices via the yahoo finance api. I tried to do this, but it didn't work:

here is the code:

Code: Select all

<php?
//get stock price using yahoo finance api, uses csv format
 
 
$ticker = "http://download.finance.yahoo.com/d/quotes.csv?s=" . $_GET["stock"] . "&f=sl1d1t1c1ohgv&e=.csv";
 
 
if (($handle = fopen($ticker, "r")) !== FALSE) {
$data = fgetcsv($handle, 1000, ","));
//splits up code to get the actual price
$actual_price = explode(",", $data[0]);
 
//actually shows the stock price:
echo $actual_price[1];
 
 
}fclose($handle);
 
?>
Can someone help me, please?