繁体   English   中英

雅虎天气API没有响应

[英]Yahoo weather API gives no response

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

我每次都会收到此异常:服务器返回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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM