使用Hutool发送Http请求
1、pom中添加依赖
<!--http请求-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.12</version>
</dependency>
2、代码如下
public static boolean takephotoontime(String clientId,String brightness,String channelId,String chroma,String command,String contrast,
String quality,String resolution,String saturation,String save,String time){
HttpRequest post = HttpUtil.createPost("http://222.74.94.190:9098/terminal/media/video/record");
post.form(PARAM_CLIENTID,clientId);
post.form(PARAM_BRIGHTNESS,brightness);
post.form(PARAM_CHANNELID,channelId);
post.form(PARAM_CHROMA,chroma);
post.form(PARAM_COMMAND,command);
post.form(PARAM_CONTRAST,contrast);
post.form(PARAM_QUALITY,quality);
post.form(PARAM_RESOLUTION,resolution);
post.form(PARAM_SATURATION,saturation);
post.form(PARAM_SAVE,save);
post.form(PARAM_TIME,time);
HttpResponse response = post.execute();
JSONObject jsonObject = JSONObject.parseObject(response.body());
String code = jsonObject.getString("code");
System.out.println(response.body());
System.out.println("********"+code);
if(RESULT_STATUS_SUCCESS.toString().equals(code)) {
return true;
}
return false;
}