How do I make a call to the Yahoo hourly weather forecast API? -
i have found yahoo weather forcast helpful.
i'm able hourly weather request here yahoo.
how can make api request above hourly weather report using yahoo api call http://weather.yahooapis.com/forecastrss?w=2502265?
you can using rest api's of programming language want use.. give java example. (similar thing applies other languages too.. )'
package tests; import org.apache.http.*; import org.apache.http.client.methods.httpget; import org.apache.http.impl.client.defaulthttpclient; import org.apache.http.util.entityutils; /** * simple java rest example using apache http library. * executes call against yahoo weather api service, * rss service (http://developer.yahoo.com/weather/). * * try twitter api url example (it returns json results): * http://search.twitter.com/search.json?q=%40apple * (see url more twitter info: https://dev.twitter.com/docs/using-search) * * apache httpclient: http://hc.apache.org/httpclient-3.x/ * */ public class apachehttprestclient1 { public static void main(string[] args) { defaulthttpclient httpclient = new defaulthttpclient(); try { // specify host, protocol, , port httphost target = new httphost("weather.yahooapis.com", 80, "http"); // specify request httpget getrequest = new httpget("/forecastrss?p=80020&u=f"); system.out.println("executing request " + target); httpresponse httpresponse = httpclient.execute(target, getrequest); httpentity entity = httpresponse.getentity(); system.out.println("----------------------------------------"); system.out.println(httpresponse.getstatusline()); header[] headers = httpresponse.getallheaders(); (int = 0; < headers.length; i++) { system.out.println(headers[i]); } system.out.println("----------------------------------------"); if (entity != null) { system.out.println(entityutils.tostring(entity)); } } catch (exception e) { e.printstacktrace(); } { // when httpclient instance no longer needed, // shut down connection manager ensure // immediate deallocation of system resources httpclient.getconnectionmanager().shutdown(); } }
there more ways same... can find many other alternate ways @ http://alvinalexander.com/java/java-apache-httpclient-restful-client-examples