//java发送get请求,并带上参数
public static String send_Get(String encode_data){
CloseableHttpClient httpClient = HttpClients.createDefault();
URIBuilder uriBuilder = null;
String data = "";
try {
uriBuilder = new URIBuilder("http://localhost.....");//你的host
uriBuilder.setParameter("key","123");
uriBuilder.setParameter("token",encode_data);
HttpGet httpGet = new HttpGet(uriBuilder.build());
CloseableHttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity entity = httpResponse.getEntity();
System.out.println(entity.getContent());
if (entity != null) {
// return it as a String
String json_result = EntityUtils.toString(entity);
System.out.println(json_result);
JSONObject jsonObject = JSONObject.parseObject(json_result);
if (jsonObject.containsKey("code") && jsonObject.get("code").toString().equals("1")){
data = jsonObject.get("data").toString();
System.out.println(data);
}
}
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}finally {
closeHTTP();
}
return data;
}