<pre>
<?php
/*
This script is for testing the php- class YahooQuotes
It tries to receive historical and intraday prices of stocks
from finance.yahoo.com. If an error occures it echoes an
errormessage.
Please check with Yahoo, Inc. if you may use these scripts
for your purpose.
*/
require ("yahooquotes.php");
$symbols = array("MSFT", "BMW.DE", "NOSUCHSYMBOL");
$from = array (2008, 7, 25); //25th July 2008
$to = array (2008, 8, 1); //1st August 2008
echo "Quotes are accessed from finance.yahoo.com\n";
foreach ($symbols as $sym) {
$quotes = new YahooQuotes ($sym, $from, $to);
if ($quotes->getHistQuotes()) {
print_r($quotes->histquotes);
if ($quotes->getTodayQuotes()) {
print_r($quotes->dayquote);
} else {
echo $quotes->ERR."\n";
}
} else {
echo $quotes->ERR."\n";
}
}
?>
</pre>
|