package builder;
|
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
import com.hikvision.artemis.sdk.config.ArtemisConfig;
|
import com.alibaba.fastjson.JSONObject;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
public class GetCameraPreviewURL {
|
private static final String host = "xxx:4433";
|
private static final String appKey = "xxxx";
|
private static final String appSecret = "xxxxx";
|
public static String GetCameraPreviewURL() {
|
|
/**
|
* STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
|
*/
|
|
|
|
|
/**
|
* STEP2:设置OpenAPI接口的上下文
|
*/
|
final String ARTEMIS_PATH = "/artemis";
|
|
/**
|
* STEP3:设置接口的URI地址
|
*/
|
final String previewURLsApi = ARTEMIS_PATH + "/api/acs/v1/door/states";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
|
}
|
};
|
|
/**
|
* STEP4:设置参数提交方式
|
*/
|
String contentType = "application/json";
|
|
/**
|
* STEP5:组装请求参数
|
*/
|
JSONObject jsonBody = new JSONObject();
|
jsonBody.put("doorIndexCodes", "748d84750e3a4a5bbad3cd4af9ed5101");
|
String body = jsonBody.toJSONString();
|
/**
|
* STEP6:调用接口
|
*/
|
ArtemisConfig artemisConfig = new ArtemisConfig(host, appKey, appSecret);
|
String result = null;// post请求application/json类型参数
|
try {
|
result = ArtemisHttpUtil.doPostStringArtemis(artemisConfig,path, body, null, null, contentType , null);
|
} catch (Exception e) {
|
throw new RuntimeException(e);
|
}
|
return result;
|
}
|
|
public static void main(String[] args) {
|
String result = GetCameraPreviewURL();
|
System.out.println("result结果示例: " + result);
|
}
|
}
|