廖井涛
2024-03-04 eae17d27ec56a6b7887f5597335e38ca40273ef4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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);
    }
}