雅虎天气 API 没有回应

Yahoo weather API gives no response

我正在尝试编写一个 java 客户端,从 yahoo weather API 获取天气 API。

我每次都会遇到这个异常: 服务器返回 HTTP 响应代码:401 用于 URL:http://weather.yahooapis.com/forecastrss?p=USCA1116

代码:

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";

    String url = "http://xml.weather.yahoo.com/forecastrss?p=USCA1116";

感谢 https://forum.rainmeter.net/viewtopic.php?f=13&t=23010