【问题标题】:How to get weather forecast for a location?如何获取某个位置的天气预报?
【发布时间】:2012-02-21 09:11:29
【问题描述】:

我想获得当前位置的天气预报(未来 5 天的预报)。

我对 Yahoo、Google、Weather.com 等 iOS 的天气 API 进行了研究……但我找不到使用天气 API(带有预测)的示例项目 p>

如果有任何示例项目或任何免费的天气报告服务可以在我的应用程序中使用。 请告诉我

提前谢谢你。

【问题讨论】:

  • 仅根据您找到的 API 编写自己的项目有什么问题?

标签: iphone objective-c ios ios4


【解决方案1】:

这个想法很简单..你必须寻找API,传递所需的参数Date range - country etc ....这将返回一个xml缓冲区..然后你可以使用目标c XML解析器..尝试谷歌parse xml objective c,你会发现很多文章。

这是一种形成旧 SOF 主题的 API (http://stackoverflow.com/questions/5775488/to-display-weather-forecast-for-currentday-next-day-and-day-after-next- ip 中的一天)。

NOAA REST Interface

Example: http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdXMLclient.php?zipCodeList=90210&product=time-series&begin=2004-01-01T00:00:00&end=2013-04-21T00:00:00&maxt=maxt&mint=mint

Yahoo! Weather Forecast RSS

Example: http://weather.yahooapis.com/forecastrss?p=90210

Google Weather API - documentation URL for this?

Example: http://www.google.com/ig/api?weather=90210

Weather Underground API

Example: http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=90210

Weather Channel - Requires signup

Example: found sample code at github. Ruby gem for accessing the Weather Channel XML API

WeatherAPI (Norway)

Example: http://api.yr.no/weatherapi/locationforecast/1.6/?lat=34;lon=-118

【讨论】:

    【解决方案2】:

    也许您可以查看 Apple 的天气小部件,看看您是否可以观察小部件如何与 weather.yahoo.com 通信,或者只是通过 WebKit 或其他方式使用它。它在 /Library/Widget/Weather.wdgt

    【讨论】:

      猜你喜欢
      • 2012-11-30
      • 2012-11-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      • 2013-02-28
      • 1970-01-01
      相关资源
      最近更新 更多