通过API获取当前天气的最佳方式?

xRo*_*bot 11 php api weather mashup weather-api

通过API获取当前天气的最佳方法是什么?

你能用这个API做一些例子吗?

hyd*_*gen 3

全球天气 SOAP Web 服务 API

使用 PHP(在 php.ini 中启用 SOAP 模块):

$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;
Run Code Online (Sandbox Code Playgroud)

然后,$weatherXML 应该包含一个 XML 文档,其中包含湿度、温度、天空条件、风等,您可以根据自己的需要进行调整。无论如何,您都可以轻松地玩 www.webservice.net 上的在线演示来感受一下。