private static String FreeApi 
= "http://freeapi.ipip.net/%s";
  private String
[] getIpInfo(String clientIp
){
        String defaultLoc
;
        String url 
= String
.format(FreeApi
, clientIp
);
        try {
            Map para 
= new HashMap();
            Map retMap 
= HttpClient
.sendGetRequest(url
, para
);
            if (!retMap
.isEmpty()) {
                String result 
= retMap
.get("raw").toString();
                JSONArray array 
= JSONArray
.parseArray(result
);
                if (!array
.isEmpty()) {
                    String country 
= array
.get(0).toString();
                    String city 
= array
.get(2).toString();
                    String isp 
= array
.get(4).toString();
                    if (country
.isEmpty()) {
                        country 
= "XX";
                    }
                    if (city
.isEmpty()) {
                        city 
= "XX";
                    }
                    if (isp
.isEmpty()) {
                        isp 
= "XX";
                    }
                    String val 
= country 
+ ";" + city 
+ ";" + isp
;
                    System
.out
.println(val
);
                    return val
.split(";");
                }
            }
        } catch (Exception var12
) {
            this.logger
.error("getIpInfo catch exception:", var12
);
        }
        defaultLoc 
= "中国;未知;XX";
        return defaultLoc
.split(";");
    }
                
                
                
        
    
 
                    转载请注明原文地址: https://lol.8miu.com/read-20126.html