| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package com.xjrsoft.module.hikvision.util;
- import com.hikvision.artemis.sdk.ArtemisHttpUtil;
- import com.hikvision.artemis.sdk.config.ArtemisConfig;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * @author dzx
- * @date 2024/4/26
- */
- public class ApiUtil {
- public final static String host = "219.153.208.43:30443";// 平台的ip端口
- public final static String appKey = "21350095";// 密钥appkey
- public final static String appSecret = "LXi9rE2fm8IfRoLnTA2G";// 密钥appSecret
- /**
- * 调用海康接口(该方法内部实现了登入认证逻辑)
- * @param apiPath 接口地址
- * @param body body参数
- * @param querys 查询参数
- * @param header header参数
- * @return 接口调用结果
- */
- public String doPost(String apiPath, String body, Map<String, String> querys, Map<String, String> header){
- /**
- * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
- */
- ArtemisConfig.host = ApiUtil.host; // 平台的ip端口
- ArtemisConfig.appKey = ApiUtil.appKey; // 密钥appkey
- ArtemisConfig.appSecret = ApiUtil.appSecret;// 密钥appSecret
- /**
- * STEP2:设置OpenAPI接口的上下文
- */
- final String ARTEMIS_PATH = "/artemis";
- /**
- * STEP3:设置接口的URI地址
- */
- final String previewURLsApi = ARTEMIS_PATH + apiPath;
- Map<String, String> path = new HashMap<String, String>(2) {
- {
- put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
- }
- };
- /**
- * STEP4:设置参数提交方式
- */
- String contentType = "application/json";
- return ArtemisHttpUtil.doPostStringArtemis(path, body, querys, null, contentType , header);// post请求application/json类型参数
- }
- /**
- * 调用海康接口(该方法内部实现了登入认证逻辑)
- * @param apiPath 接口地址
- * @param body body参数
- * @param querys 查询参数
- * @return 接口调用结果
- */
- public String doPost(String apiPath, String body, Map<String, String> querys){
- return doPost(apiPath, body, querys, null);
- }
- }
|