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

时间:2010-09-03 22:50:39

标签: php api weather mashup weather-api

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

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

5 个答案:

答案 0 :(得分:3)

Global Weather SOAP Webservice 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;
然后,$ weatherXML应该包含一个XML文档,其中包含您可以根据需要调整的湿度,温度,天空条件,风等。无论如何,您可以轻松地使用www.webservice.net上的在线演示来感受事物。

答案 1 :(得分:2)

在梨上尝试Services_Weather。它有全球天气,METAR等。人。

答案 2 :(得分:1)

我在mashape上提供了Weather API,他们已准备好使用简单的PHP SDK。 这个api非常简单易用,因为我们使用现在可用的酷标准,如JSON和REST。

如果您喜欢,请试试mashape

答案 3 :(得分:1)

Programmable Web有一个list of Weather API's。目录中列出了26个Weather API。更受欢迎的服务将拥有适用于通用平台的库,因此请查看php库。

答案 4 :(得分:0)

Weather Underground (wunderground.com) - 从weather.com的页脚链接中找到它。

免费:对于0美元,您每天可获得500次API调用或每次调用10次API调用

注意:当您首先注册帐户然后时,它会更有效,在登录时,购买您的API密钥。