I am using yahoo weather api and getting result using this link:
Now I want to using this url with retrofit. So please tell me how to change the city by passing query.
Thank you
It would end up being something like this:
public interface WeatherService {
@GET("v1/public/yql")
Call<String> getWeather(@Query("q") String query);
}
Then create the object like this:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://query.yahooapis.com")
.addConverterFactory(ScalarsConverterFactory.create())
.build();
WeatherService wService = retrofit.create(WeatherService.class);
And run it like this:
String query = "select * from weather.forecast where woeid in (select woeid from geo.places(1) where text=\"Leeds\")&format=json";
Call<String> weather = wService.getWeather(query);
try {
Response<String> resp = weather.execute();
You should change the ConverterFactory to json and properly parse the weather output.
I have not tested this, just giving you an idea of how to use the Retrofit query.