使用HttpClient为GET/POST请求获取数据 -- 信任证书 SS连接
依赖部分
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
使用GET请求获取数据
public static String apiGetRequest(String url, Map<String, String> header, Map<String, String> parameterDataMap, int socketTimeout, int connectTimeout) throws IOException {
if (!CollectionUtils.isEmpty(parameterDataMap)) {
try {
URIBuilder uriBuilder = new URIBuilder(url);
if (!CollectionUtils.isEmpty(parameterDataMap)) {
parameterDataMap.entrySet().forEach(e -> {
uriBuilder.addParameter(e.getKey(), e.getValue());
});
}
url = uriBuilder.build().toString