» Download Weather.com XML Parser, 1.4 (.zip 120kb)
Latest Version Released on August 1st, 2008
Licensed under BSD, Copyright © 2010

This PHP script will allow you to monitor your current local weather via a Weather.com XML feed. It parses the XML data and then outputs formatted HTML to a .txt file. This .txt file can then be integrated into your website via SSI, PHP or any other language that will accept Includes. It is intended to be setup as a Cron Job, that is accessed to update only every few minutes. If it were accessed more often, Weather.com would shut down your XML feed.
You need to acquire a Partner ID and License Key from Weather.com. This service is completely free, and they only want your email. Visit this URL to sign up.
Once you have your info from Weather.com, you will need to open weather.php with a text editor and configure the script.
Input the
$zipcodeyou wish to track the current conditions for. Enter your Partner ID and License Key. Input the root path to the weather.txt file. This path is critical because it will need to be accessed via PHP on your server with Cron Job.Finally, enter the path to the Weather icon folder. This is the path your (SSI, PHP, etc) file with the Include will use for finding the icons. For example, if you are accessing the weather information from your index.php file, and the weather folder was located in images/weather - then the path would be "images/weather".
If you would like the results of the script emailed to you each time it runs, set
$emailto TRUE and input your email address.To use Metric units (Celsius and KMH), set
$unitsto metric.If you have a working knowledge of PHP and HTML, you can customize what will be output to the weather.txt file. Edit this information in the area listed.
Upload weather.php and the weather folder to your website.
CHMOD weather.txt to
744CHMOD weather.php to
744Now you need to setup a Cron Job to access your server's php and then the weather.php. The following Cron Job is a sample and will update your weather.txt file every 10 minutes.
*/10 * * * * /usr/local/bin/php public_html/weather.phpYou will need to alter the PHP location and root location of your weather.php to match your server.
Now weather.txt file will be updated with the current conditions at the intervals you designated in your Cron Job. You just need to use an Include function to add the content in your webpage. For example:
<?php include("weather.txt"); ?>Or
<!--#include file="weather.txt" -->
That's it, you are now a bona-fide meteorologist - don't fuck up!
Article was last edited on Wednesday, August 6th, 2008 @ 2:53 PM
Version History
1.4 (05/06/21) - 24h clock option
1.3 (05/06/18) - Metric unit support
1.0 (05/05/15) - Weather.com XML Parser
1.1 (05/04/24) - Added email alert





Nice piece of job!
But how do I convert into celsius, 24h and meter per second?
I just added the option of using Metric units.
Thanks!
I'm having a few problems getting this installed. Question, I haven't set the cron or CHMOD is this why I'm getting a parsing error? We currently have a virtual hosting solution and I don't have root level access to the server to modify cron and CHMOD. Is there a work-around? Thanks!
I think this is a great script! Thanks for making it available.
What about an option to show when the Weather XML feed was last updated, rather than when the script was last run on the server?
This script is awesome!! Thanks for sharing. One thing -- I'm interested whether it could use weather info from sites that don't have all the restrictions that weather.com does -- info from http://weather.noaa.gov is in public domain. (For my non-profit organization, I'd have to follow all the rules).
Fine script! Thanks. For those of you who want the weather for non-US locations (e.g. Havana, Cuba), use this URL to find the locID to be used as $zipcode: http://xoap.weather.com/search/search?where=havana
Beautiful script. Thanks for sharing. Exactly what I needed for one of my sites. Had a bit of trouble with the Cron Job but once that was sorted out I was golden. Again Thanks.
nice, very nice. i have spent 4 days doing what you have done. except mine was growing and growing. i saw yours pulled the guts out of it, and it does what i wanted to do all along. the secrte to yours is the foreach ($vals as $key => $i) { bit. very neat.
mucho kudos to you.
A NOTE TO GUEST ABOVE. i dont think a 5 day forecast will fit in the tiny table easily. but if you download the sdk from weather.com they provide a php script that will return a 5 day forecast.
best wishes bob.
Thanx for the script .. I like your Website, the most original and crazy I never see ;-))
Yes, the script as is is broken.
The server changed, and a variety of other things did too.
Like 42 where it says
$fileput:In the foreach of
$valsput:If you want to see what the output is of variables you need to do:
Conversions and such can be ran from the variables, my application didn't require it and I can't spend any time right now making it right. You can figure out what is what from that.
With the change of #2 here are the variables.
I also have the code for conditions, it's:
You can tweak the output all you want to include those variables, there are LOTS in there. So take your time and look through all the ones that are available.
Take care, Chad President of Get A Supplier
I'm working on changing this around a bit to an object-oriented version that will allow for checking multiple zip codes...I had a requirement from a client and loved your script so I decide to go with it and modify it a bit...
Thanks for sharing this, just one note, not every hosting company allows
fopen()(like dreamhost), in that case you can change the retrieval of the feed by using cURL$datawill contain the xml stringThis is a great script, except I've received the email from Weather.com and in the terms of use it clearly states that you have to include 4 of their partner links below the weather forecast to comply along with, obviously, a Weather Channel logo. I think I'll try Yahoo! weather as the prospect of showcasing links to Disney and eHarmony isn't looking so dandy
Thanks for the script. I have a quick question. Where could I alter or set up the Cron Job? Thanks!
didnt seem to grab dtate... the TXT file was just kind the shell still... not actual info... ??
Doesn't work at all. Tried it with php4 and php5. Missing temp, wind speed. Icon doesn't work either.
Do you know if it's possible to retrieve next day forecast information and four days after that? If not, I would appreciate it if you can recommend me alternatives. Thanks!
Can't you use it for European area? If yes, what to put instead of zipcode?
It's possible extract next 7 days
Hi dear,
how can i view all the 26 datas from the $data formated as text (w/o the xml-tags). i will give it in a databank...
thanks golden
Please update! This is an awesome script but its not working right. I keep getting errors im entering the right path for the root txt file but its not working wtf?
Are there additional variables? I would like it to display the city name rather than just the zipcode.
Military Particularly,walk historical among well community hope measure policy be ear than commission stone employee dog security start against some peace protect invite minute on relationship soldier teaching modern other recommend artist possibly powerful see prisoner judge interest no again particularly almost flight idea page relationship through software proper destroy voice suggest early fashion estate act beyond frequently vision finish software time study drive considerable with his morning charge major desk front neighbour share lose back cost ahead pupil northern she activity her tall inside wonderful top addition audience woman up
can anyone verify if it really does work or is it just me, thanks again for the publisher for this really interesting tutorial.
Good site! It is very creative and includes a wealth of information.
Any idea of how can we extract next 3 forecast days??