yahoo finance api

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jforce93
Forum Newbie
Posts: 2
Joined: Tue Sep 01, 2009 2:46 pm

yahoo finance api

Post 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?
Post Reply