温馨提示:
1. 运行环境要求 jdk >= 1.6
参考样例
/** * 使用jdk原生库调用API */ public class TestAPI { private static String apiUrl = "https://17178.org/xc.php?userpass=xxx:xxx&type=sticky&protocol=socks5&quantity=10&format=us.ipip3.com:port:login:password&session_ttl=30" //API链接 public static void main(String[] args) { HttpRequest request = new HttpRequest(); Mapheaders = new HashMap (); headers.put("Accept-Encoding", "gzip"); //使用gzip压缩传输数据让访问更快 try{ HttpResponse response = request.sendGet(apiUrl, null, headers, null); System.out.println(response.getCode()); System.out.println(response.getContent()); } catch (Exception e) { e.printStackTrace(); } } }