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 ?
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.
Try Services_Weather on pear. It does Global Weather, METAR, et. al.
I made a Weather API available on mashape, and they have a ready to use simple PHP SDK. This api is really simple to use because we use the cool standards that are available nowadays, like JSON and REST.
If you like it please give it a try on mashape
Programmable Web has a list of Weather API's. There are 26 Weather APIs listed in their directory. The more popular services will have libraries for common platforms so look there for a php library.
Weather Underground (wunderground.com)—found it from a link from weather.com's footer.
FREE: For $0, you get 500 API calls/day or 10 API calls/min
NOTE: It works better when you register an account first, then, while signed in, purchase your API key.
精彩评论