【发布时间】:2016-01-30 07:47:48
【问题描述】:
我正在使用 OpenWeather API,并在 Retrofit 上进行了第一次尝试。我正在尝试将预测拉到 X 天。可以在此处找到预测 API 的文档:
http://openweathermap.org/forecast16
看起来特定城市预测的 API 的相关链接如下:
api.openweathermap.org/data/2.5/forecast/daily?q={city name},{country code}&cnt={cnt}
我的基本网址是:
api.openweathermap.org/data/2.5/forecast/daily?
我对如何满足 @GET 注释以及异步响应的关联方法感到有些困惑。 API 链接中的“&”也令人困惑,因为我真的不知道我会在 @GET 注释中包含 API 调用的静态部分。这是我所拥有的:
public interface WeatherAPI {
@GET("/forecast/daily?")
void getResponse(@Query("city")String city, @Query("country_code") int countryCode, @Query("number_of_days") int number_of_days, Callback<List<WeatherForecast>> response);
}
对于这个特定问题以及如何解决整体改造问题的任何帮助将不胜感激。
【问题讨论】: