Login   Register  
PHP Classes
elePHPant
Icontem

File: test_yahooquotes

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2008-10-28 07:42
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 (2008725);   //25th July 2008
$to   = array (20088,  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>