Print weather reports with PEAR Services_Weather


One of the great pear packages Services_Weather, it offer an easy access to weather services such GlobalWeather from CapeScience, Weather XML from EJSE (US only), a XOAP service from and METAR/TAF from NOAA. This is already a great collection !!

I used to print some weather reports in some special periods of the year, and it’s one of the annoying task that I was doing before but not anymore ! I decided to implement a weather printing report service and used PEAR Weatherdotcom class to communicate with the webservice more easily. The only problem that the package isn’t well documented, but here is how to proceed for weather forecast.


The weather API is pretty easy, not a real webservice. A simple URL where you setup different options which return XML with available data. So first install Services_Weather package :

Then we can include the class and use it. Since it wasn’t documented, I used directly the Weatherdotcom.php class. First thing to do is to create a free account at XMLOAP service from, and get your partnerID and LicenseKey :

Now you should be able to retrieve forecast for the next ten days :

The ‘m’ is to mean metrics results, then $forecast will be an array filled with XML data from

Now you can personalize these data in the report you want, there is PNG icons that you’ll find with the SDK after registration at XOAP. But if you are going to use it with print I’ll suggest you to convert the PNG to white background and use white background for the images in question. And if you are lazy just like me and have your PHP print extension working fine, you can send your report directly to your boss’s printer. Hope this was useful.

Previous articleElection 2.0
Next article363,6363636
Hatem Ben Yacoub, Energy engineer, Entrepreneur, ICT & eGov consultant, ITIL v3 Certified, Certified Document Imaging Architect (CDIA+), Senior Systems architect, PHP expert and PHP5.3 ZCE, OpenGov/OpenData Advocate, and Open source Evangelist.