I am trying to write a java client that get the weather from yahoo weather API.
I get this exception every time: Server returned HTTP response code: 401 for URL: http://weather.yahooapis.com/forecastrss?p=USCA1116
the code:
public class Main {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
// log.info( "Retrieving Weather Data" );
String zipcode="USCA1116";
String url = "http://weather.yahooapis.com/forecastrss?p=USCA1116";
URLConnection connection = new URL(url).openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
connection.getInputStream()));
String decodedString;
while ((decodedString = in.readLine()) != null) {
System.out.println(decodedString);
}
in.close();
}
}
any ideas?!