Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to get Current Weather via API?

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

Could you make some example with this API ?

like image 527
xRobot Avatar asked Sep 03 '10 22:09

xRobot


People also ask

Is there a free weather API?

Open-Meteo collaborates with National Weather Services providing Open Data with 2 to 11 km resolution. Our high performance APIs select the best weather model for your location and provide data as a simple JSON API. APIs are free without any API key for open-source developers and non-commercial use.

Is there a weather API?

Overview. The National Weather Service (NWS) API allows developers access to critical forecasts, alerts, and observations, along with other weather data. The API was designed with a cache-friendly approach that expires content based upon the information life cycle.

Does Google have a weather API?

Google does not have its own weather API, it fetches data from weather.com and shows it when you search on Google.


1 Answers

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.

like image 135
hydrogen Avatar answered Oct 04 '22 04:10

hydrogen