【问题标题】:Android - Retrofit - Query - Yahoo WeatherAndroid - 改造 - 查询 - 雅虎天气
【发布时间】:2016-07-06 12:29:10
【问题描述】:

我正在尝试使用 Retrofit 向 Yahoo 请求当前天气。 我在试图通过这座城市时遇到了一个问题。我知道我必须使用@Query

Yahoo 查询有点复杂,我不知道如何继续。 这是我的代码

@GET("yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20**text%3D%22brussels%2C%20be%22)%20and%20u%3D%27c%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys")

在这个复杂的查询中,我需要从 例如,text%3D%22brussels%2C%20betext%3D%paris%2C%20fr

任何帮助将不胜感激;

提前致谢,

【问题讨论】:

    标签: android retrofit yahoo weather


    【解决方案1】:
    @GET("yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20**text%3D%22{location}%2C%20be%22)%20and%20u%3D%27c%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys")
    Call<response> groupList(@Path("location") String location);
    

    如果我正确理解您的问题,这应该可以。

    【讨论】:

    • 谢谢蒂姆。所以我在我的活动中,我需要传递城市变量,但这是我卡住的地方。如果我这样传递: WeatherAPI.Factory.getmWeatherAPI().getWeather(city).enqueue(new Callback - 据说我必须使用查询:-/ 这是消息:不能有替换块. 对于动态查询参数,请使用@Query。
    猜你喜欢
    • 2017-09-03
    • 1970-01-01
    • 2013-07-06
    • 2012-08-16
    • 2013-02-09
    • 2014-11-20
    • 1970-01-01
    • 1970-01-01
    • 2011-11-15
    相关资源
    最近更新 更多