Best way to get Current Weather via API?

xRobot picture xRobot · Sep 4, 2010 · Viewed 17.9k times · Source

What is the best way to get current weather via API ?

Could you make some example with this API ?

Answer

hydrogen picture hydrogen · Sep 4, 2010

Global Weather SOAP Webservice API

Using PHP (with the SOAP module enabled in your php.ini):

$client = new SoapClient("http://www.webservicex.net/globalweather.asmx?wsdl");
$params = new stdClass;
$params->CityName= 'Auckland';
$params->CountryName= 'New Zealand';
$result = $client->GetWeather($params);
// Check for errors...
$weatherXML = $result->GetWeatherResponse;

$weatherXML should then contain an XML document that contains humidity, temperature, sky conditions, wind etc that you can adapt to your needs. You can easily play with the online demo on www.webservice.net anyway to get a feel for things.