Location: PHPKode > scripts > PHP Yahoo Weather Class > php-yahoo-weather-class/documentation.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0077)http://www.phpclasses.org/browse/download/1/file/11527/name/documentation.htm -->
<HTML><HEAD><TITLE>Free PHP Yahoo Weather Class</TITLE>
<META http-equiv=Content-Language content=de-ch>
<META content="Microsoft FrontPage 5.0" name=GENERATOR>
<META content=FrontPage.Editor.Document name=ProgId>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY bgColor=#f4f4f4>
<DIV 
style="BORDER-RIGHT: #cc3300 4px solid; BORDER-TOP: #cc3300 4px solid; BORDER-LEFT: #cc3300 4px solid; BORDER-BOTTOM: #cc3300 4px solid; BACKGROUND-COLOR: #808080">
<P align=center><B><FONT face=Arial color=#ffffff size=7>Free PHP Yahoo Weather 
Class!</FONT></B></P>
<P align=center><b><font face="Arial" size="7" color="#FFFFFF">V2.0</font><U><FONT face=Arial size=5><BR>&nbsp;</FONT></U></b></P></DIV>
<P><B><FONT face=Arial color=#cc3300>1) WHAT IT IS?!</FONT></B></P>
<DIV 
style="BORDER-RIGHT: #cc3300 5px solid; PADDING-RIGHT: 4px; BORDER-TOP: #cc3300 5px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: #cc3300 5px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #cc3300 5px solid; BACKGROUND-COLOR: #808080"><FONT 
face=Arial size=2><B><FONT color=#ffffff>This class delivers you the weather 
data from </FONT><A href="http://weather.yahoo.com/"><FONT 
color=#ffffff>http://weather.yahoo.com</FONT></A><FONT color=#ffffff>! It uses 
the free RSS stream from yahoo. The class is very easy to use. Also an 
automatically caching is integrated. So the rss has not to be loaded every hit 
to the page! You can define the cache lifetime by your self. Enjoy 
it!!! Thanks to Matt Brown for this new version.</FONT></B></FONT></DIV>
<P><FONT face=Arial><FONT color=#cc3300><B>2</B></FONT><B><FONT color=#cc3300>) 
DEMO</FONT></B></FONT></P>
<DIV 
style="BORDER-RIGHT: #cc3300 4px solid; BORDER-TOP: #cc3300 4px solid; BORDER-LEFT: #cc3300 4px solid; BORDER-BOTTOM: #cc3300 4px solid">
<P align=center><B><FONT face=Arial size=2>The demo is available by clicking on 
the following link! This test script shows you all attributes, that the class 
delivers!</FONT></B></P>
<P align=center><B><FONT face=Arial color=#cc3300><FONT 
color=#cc3300>
<a target="_blank" href="http://www.voegeli.li/development/class.yahoo.weather2/weather.test.php">
http://www.voegeli.li/development/class.yahoo.weather2/weather.test.php</a></FONT> 
(new window)<BR>&nbsp;</FONT></B></P></DIV>
<P><FONT face=Arial color=#cc3300><B>3) DOWNLOAD</B></FONT></P>
<DIV 
style="BORDER-RIGHT: #cc3300 4px solid; BORDER-TOP: #cc3300 4px solid; BORDER-LEFT: #cc3300 4px solid; BORDER-BOTTOM: #cc3300 4px solid">
<P align=center><B><FONT face=Arial size=2>Download the file from one of the 
following locations:</FONT></B></P>
<P align=center>(use www.phpclasses.org or www.voegeli.li)<BR>&nbsp;</P></DIV>
<P><FONT face=Arial color=#cc3300><B>4) USAGE EXAMPLE (VERY EASY)</B></FONT></P>
<DIV 
style="BORDER-RIGHT: #cc3300 4px solid; BORDER-TOP: #cc3300 4px solid; BORDER-LEFT: #cc3300 4px solid; BORDER-BOTTOM: #cc3300 4px solid"><FONT 
face=Arial size=2><B>Take a look at the following using example! This is taken 
from the test script, which is included in the download archive. If you want t 
know more about attributes and methods, read the following 
points.<BR>&nbsp;</B></FONT>
<DIV style="BACKGROUND-COLOR: #f4f4f4"><B><FONT face="Courier New" 
size=2><BR>include("class.xml.parser.php");<BR>include("class.weather.php");<BR><BR>$weather_chile 
= new weather("CIXX0020", 3600, "C", $cachedir);  </FONT></B>
  <p><B><FONT face="Courier New" 
size=2>// LocationCode, seconds cachelifetime, 
TempUnit (F or C), Directory for cache<BR><BR>$weather_chile-&gt;parsecached(); 
<BR><BR>&nbsp;</FONT></B></DIV></DIV>
<P><FONT face=Arial color=#cc3300><B>5) METHODS</B></FONT></P>
<P><B><FONT face=Arial size=2>The following methods are provided by the 
class.</FONT></B></P>
<TABLE id=AutoNumber1 style="BORDER-COLLAPSE: collapse" borderColor=#111111 
cellSpacing=0 cellPadding=0 width="100%" border=1>
  <TBODY>
  <TR>
    <TD width="50%" bgColor=#808080><B><FONT face=Arial color=#ffffff 
      size=2>&nbsp;Method</FONT></B></TD>
    <TD width="50%" bgColor=#808080><B><FONT face=Arial color=#ffffff 
      size=2>Description</FONT></B></TD></TR>
  <TR>
    <TD width="50%"><B><FONT face=Arial size=2>Constructor Method:</FONT></B>
      <P><B><FONT face=Arial size=2>object = new weather(</FONT><FONT 
      face="Courier New" size=2>"CIXX0020", 3600, "C"</FONT><FONT face=Arial 
      size=2>, $directory);</FONT></B></P>
      <P>&nbsp;</P></TD>
    <TD width="50%"><B><FONT face=Arial size=2><BR>This is the constructor 
      method, automatically called, when you make the instance. There are 3 
      Parameters you have to pass:</FONT></B>
      <UL>
        <LI><FONT face="Courier New" size=2><B>"CIXX0020" = Location Code from 
        weather.Yahoo.com</B></FONT> 
        <LI><B><FONT face="Courier New" size=2>(Go to weather.yahoo.com, search 
        in the browser for location, click on location link and look in the 
        browsers URL field for the Code Param (at the end!)</FONT></B> 
        <LI><B><FONT face="Courier New" size=2>3600 = 3600 seconds (1 hour) 
        lifetime of the cache object. By using method parsecached() this 
        defines, when the RSS has to be automatically reparsed from RSS (If not 
        needed pass "0")</FONT></B> 
        <LI><B><FONT face="Courier New" size=2>"C" = Celsius. This is the unir, 
        in which the temperature should be taken ("F" = Fahrenheit / "C" = 
        Celsius)</FONT></B> </LI> 
        <LI><b><font face="Courier New" size="2">$directory = temp cache dir</font></b></LI></UL></TD></TR>
  <TR>
    <TD width="50%"><B><FONT face=Arial size=2>&nbsp;parse()</FONT></B></TD>
    <TD width="50%"><B><FONT face=Arial size=2><BR>This method parses the 
      weather data from RSS every call!!! That means every time, when you call 
      this method, the weather data are refreshed from the RSS from 
      weather.yahoo.com. This may be very slow (needs every hit a connection to 
      the Yahoo server!). <BR><FONT color=#cc3300><U>NOT</U> </FONT><FONT 
      color=#cc3300>RECOMMENDED</FONT><BR>&nbsp;</FONT></B></TD></TR>
  <TR>
    <TD width="50%"><B><FONT face=Arial 
    size=2>&nbsp;parsecached()</FONT></B></TD>
    <TD width="50%"><B><FONT face=Arial size=2><BR>This method parses the RSS 
      only if needed! That means it looks on your local server, if there's a 
      valid object cache file (named like the location code). If there is no 
      cached version, it automatically parses the object from RSS 
      weather.yahoo.com, writes the object with a specified lifetime down to 
      your local server! Very enhanced! Very usefull and VERY FAST!! <BR><FONT 
      color=#cc3300>RECOMMENDED!!!<BR>&nbsp;</FONT></FONT></B></TD></TR></TBODY></TABLE>
<P><FONT face=Arial color=#cc3300><B>6) ATTRIBUTES</B></FONT></P>
<P><B><FONT face=Arial size=2>Here is the complete list of the class attributes 
with a description:</FONT></B></P>
<P><b><font face="Arial" size="2">The classes attributes are all shown in the 
test-script attached! Please use this.</font></b></P>
<TABLE style="WIDTH: 639px; BORDER-COLLAPSE: collapse" borderColor=#000000 
cellPadding=3 border=1>
  <COLGROUP>
  <COL style="WIDTH: 60pt" width=80></COLGROUP>
  <TBODY>
  <TR style="HEIGHT: 12.75pt" height=17>
    <TD 
    style="BORDER-RIGHT: medium none; PADDING-RIGHT: 1px; BORDER-TOP: medium none; PADDING-LEFT: 1px; FONT-WEIGHT: 400; FONT-SIZE: 10pt; VERTICAL-ALIGN: bottom; BORDER-LEFT: medium none; COLOR: windowtext; PADDING-TOP: 1px; BORDER-BOTTOM: medium none; FONT-STYLE: normal; FONT-FAMILY: Arial; WHITE-SPACE: nowrap; HEIGHT: 12.75pt; TEXT-DECORATION: none" 
    width=172 height=17 x:str="fore_day5_imgcode "></TD>
    <TD 
    style="BORDER-RIGHT: medium none; PADDING-RIGHT: 1px; BORDER-TOP: medium none; PADDING-LEFT: 1px; FONT-WEIGHT: 400; FONT-SIZE: 10pt; VERTICAL-ALIGN: bottom; BORDER-LEFT: medium none; COLOR: windowtext; PADDING-TOP: 1px; BORDER-BOTTOM: medium none; FONT-STYLE: normal; FONT-FAMILY: Arial; WHITE-SPACE: nowrap; HEIGHT: 12.75pt; TEXT-DECORATION: none" 
    width=463 height=17 x:str="fore_day1_imgcode "></TD></TR></TBODY></TABLE></BODY></HTML>
Return current item: PHP Yahoo Weather Class