PHP Classes

File: test_yahooquotes

Recommend this page to a friend!
  Classes of Andreas Vollenklee   Yahoo Quotes   test_yahooquotes   Download  
File: test_yahooquotes
Role: Example script
Content type: text/plain
Description: script to test the functionality of class YahooQuotes
Class: Yahoo Quotes
Retrieve stock quotes from Yahoo Finance
Author: By
Last change:
Date: 15 years ago
Size: 860 bytes
 

Contents

Class file image Download
<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>