简体   繁体   English

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

[英]Best way to get Current Weather via API?

What is the best way to get current weather via API ? 通过API获取当前天气的最佳方法是什么?

Could you make some example with this API ? 你能用这个API做一些例子吗?

Global Weather SOAP Webservice API 全球天气SOAP Web服务API

Using PHP (with the SOAP module enabled in your php.ini): 使用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 should then contain an XML document that contains humidity, temperature, sky conditions, wind etc that you can adapt to your needs. 然后$ weatherXML应该包含一个XML文档,其中包含湿度,温度,天空条件,风等,您可以根据自己的需要进行调整。 You can easily play with the online demo on www.webservice.net anyway to get a feel for things. 无论如何,您可以轻松地使用www.webservice.net上的在线演示来感受事物。

Try Services_Weather on pear. 在pear上尝试Services_Weather It does Global Weather, METAR, et. 它有全球天气,METAR等。 al. 人。

I made a Weather API available on mashape, and they have a ready to use simple PHP SDK. 我在mashape上提供了一个Weather API ,他们可以使用简单的PHP SDK。 This api is really simple to use because we use the cool standards that are available nowadays, like JSON and REST. 这个api非常简单易用,因为我们使用现在可用的酷标准,比如JSON和REST。

If you like it please give it a try on mashape 如果你喜欢它,请试试mashape

Programmable Web has a list of Weather API's . 可编程Web有一个Weather API列表 There are 26 Weather APIs listed in their directory. 目录中列出了26个Weather API。 The more popular services will have libraries for common platforms so look there for a php library. 更受欢迎的服务将拥有适用于通用平台的库,因此请查看php库。

Weather Underground (wunderground.com) —found it from a link from weather.com's footer. Weather Underground(wunderground.com) -从weather.com的页脚链接中找到它。

FREE: For $0, you get 500 API calls/day or 10 API calls/min 免费: 0美元,每天可获得500次API调用或每次调用10次API

NOTE: It works better when you register an account first, then , while signed in, purchase your API key. 注意:首先注册帐户时效果会更好, 然后在登录时购买API密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM