Java 雅虎天气API没有回应
我正试图编写一个java客户端,从yahoo weather API获取天气信息 我每次都会遇到这样的异常: 服务器为URL返回了HTTP响应代码:401: 守则:Java 雅虎天气API没有回应,java,url,yahoo,Java,Url,Yahoo,我正试图编写一个java客户端,从yahoo weather API获取天气信息 我每次都会遇到这样的异常: 服务器为URL返回了HTTP响应代码:401: 守则: public class Main { /** * @param args */ public static void main(String[] args) throws Exception { // TODO Auto-generated method stub
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();
}
}
有什么想法吗 只要更换
String url = "http://weather.yahooapis.com/forecastrss?p=USCA1116";
与
截至3月15日的积分请求需要更新为Oauth 1.0。看见
String url = "http://xml.weather.yahoo.com/forecastrss?p=USCA1116";