Jump to content

thekirbster

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About thekirbster

  • Rank
    Newbie
  1. So I've been trying to put together a little weather application using the NOAA's weather feed. The site I am connecting to is http://graphical.weather.gov/xml/ Basically, I'm a newbie when it comes to PHP. I want to code it such that a user can enter a zip code and retrieve a host of climatic data. If any one is familiar with tapping into this database (the NDFD) and could help, I'd be very grateful. Below is the code. I first want to retrieve the latitude and longitude of a given zip code and then, because both coordinates are given as a string, I want to break them up into $Lat and $Lon, respectively, and I've been successful with these specific steps. However, I believe I am running into trouble generating the XML from the $result variable and running into trouble with the subsequent parsing on the XML. I'm thinking the issue is with how I am calling the NuSoap client and associated NDFD server file. Anyways, here's the code, and I'd be very appreciative of any help. Thanks. <?php /* http://sourceforge.net/projects/nusoap/ */require('../lib/nusoap.php'); $getZip = array('zipCodeList' => $_GET['zipCodeList']); try{ $c = new nusoap_client('http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl', 'wsdl'); $LatLonList = $c->call('LatLonListZipCode',$getZip); $LatLonStr = $LatLonList; $LatLon = explode(',', $LatLonStr, 2);$Lat = ($LatLon[0]);$Lon = ($LatLon[1]); $parameters = array('product' => 'glance','numDays' => 5,'format' => '24 hourly','latitude' => $Lat, 'longitude' => $Lon); $result = $c->call('NDFDgen', $parameters);}catch (Excepion $ex){/* nuSOAP throws an exception is there was a problem fetching the data */echo 'failed';} /* parse the XML data into a giant data object */try{$xml = new SimpleXMLElement($result);}catch (Exception $ex){/* the XML was probably invalid */die('Failed to parse the XML');}
×
×
  • Create New...