» Download Weather.com XML Parser, 1.4 (.zip 120kb)
Latest Version Released on December 24th, 2012
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.
$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
To use Metric units (Celsius and KMH), set
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
CHMOD weather.php to
Now 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.php
You 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"); ?>
<!--#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
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