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.
Answer from Gary Bak on Stack OverflowHow can I utilize Yahoo Weather API in android - Stack Overflow
Yahoo weather API 7 Day forecast in Android App - Stack Overflow
How to get 7 day weather forecast using Yahoo API in Android? - Stack Overflow
Weather APIs For Android - Stack Overflow
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.
If I understand well, you are looking for a way to include a given city to the url. Here is a sample code on how to do so. In the example the variable city could take any given city name.
var city = "london";
var query = "select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22"+ city +"%22)&format=json"
Update:
then you could concatenate the query to the base url like this :
var baseurl = "https://query.yahooapis.com/v1/public/yql?q=" + query;
I made a wrapper for Yahoo Weather API on android. Check it here: https://github.com/zh-wang/YWeatherGetter4a
yes u can use yahoo weather api
http://developer.yahoo.com/weather/ check this one it provides api for having weather inforamation for any city
http://weather.yahooapis.com/forecastrss?w=2502265 as below link will give u weather information for Sunnyvale which have WOEID=2502265 which is defined at above link after w..
and for different woied id for different city u can use this api http://where.yahooapis.com/geocode?q=ahmedabad=[yourappidhere]
put ur city name after "q" at this link
i hope this will solve ur issue
After visiting So many sites, I got to know that Yahoo does not support multiple languages for the weather API response.
Yes, I think Yahoo Weather does not support multiple languages, Yahoo only take 2 parameters w (WOEID) and u (unit).
But you could consider use strings.xml to map the weather code.
For example in values/strings.xml you put not available, then in values-fr/strings.xml you put pas disponible
You need to do this for all Yahoo Weather code from 0 - 3200. And put another folder values-[country_code] for another language. Go further reading here, http://developer.android.com/guide/topics/resources/localization.html