Thursday, April 19, 2007

Getting weather in PHP

Just a quick tip how to get weather from weather.gov using their SOAP WSDL weather service. You will need to know the latitude and longitude of the place you are getting weather for.

First, make sure you have the --enable-soap extension installed.

Then it is just two lines of code:

$client = new SoapClient('http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl#NDFDgen');

$result = $client->NDFDgen(40.7893,-96.6938,'glance','2007-04-20T00:00','2007-04-21T00:00',NULL);

More information here:

http://www.nws.noaa.gov/forecasts/xml/

1 comment:

Jaffe said...

Hey, I recently added a news widget from www.widgetmate.com to my blog. It shows the latest news, and just took a copy and paste to implement. Might interest you too.