日期:2014-05-17  浏览次数:20791 次

求助大神,java调用新浪微博http接口的问题!
本帖最后由 u012492039 于 2013-11-15 16:02:59 编辑
 Upload upload = new Upload();
        String picPath = upload.readSinaValue().getProperty("AppKey");
        URL url = new URL("https://api.weibo.com/2/users/show.json?source="+picPath+"&uid="+uid);  
        BufferedReader in = new BufferedReader(  
                    new InputStreamReader(  
                     url.openStream()));  
      
        String inputLine;  
      
        while ((inputLine = in.readLine()) != null)  
         System.out.println(inputLine);  
      
         in.close();  
         return inputLine  ;

直接在网址打开这个url返回的是一个json字符串
但是方法走到url.openStream()就报错了
java?新浪微博接口

------解决方案--------------------
因为它是禁制抓取它的网页数据。加上他试试("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
如果没有用的话,估计得找其他方法。