提示
java使用 SpringBoot 框架
jdk使用 1.8版本
海康
通过访问 OpenAPI 文档中心的方式可以验证 API 网关是否安装成功,访问地址
http://IP:Port/artemis-portal/document 打开文档中心(其中 IP:Port 以及 http 头与登录门户页面信息保
持一致)。
相关文件
开发准备
环境
ip,prot
门户登录地址,注意端口要和所选的协议匹配(http 默认端口 80,https 默认 端口 443,如有修改,以实际端口为准);
参数
appkey ,secret
Appkey/Secret:合作方 Key 和 Secret(从运管中心-状态监控-API 网关-API 管理-合作方 管理,点开具体合作方获得);
工具使用
-
视频WEB插件
浏览器插件播放
-
OpenApi 签名生成工具
根据签名使用postman调用调试
X-Ca-Key:appKey,即 AK。
X-Ca-Signature:签名,以 appSecret(即 SK)为密钥,
X-Ca-Signature-Headers:请求头,填写有值字段
以上字段为必填值
获取签名 使用postman调取接口
- OpenAPI 接口测试工具
根据参数直接调取
引入海康依赖
pom.xml
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<version>1.1.3</version>
</dependency>
java文件
package com.landy.framework.web.controller;
// 引入类
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.landy.framework.common.Response; //自定义 Spring Boot 相应包
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
获取监控列表
@RestController
@RequestMapping("/api/camera")
@Api(tags = "1-海康威视接口")
@ApiSupport(order = 1)
public class TWaternetCameraController {
@ApiOperation(value = "1-查询视频列表", notes = "调用海康威视接口查询视频列表")
@GetMapping("/cameraSearch")
public Response cameraSearch(Integer pageNo, Integer pageSize) {
return Response.ok(this.GetCameraPreviewURL("/api/resource/v2/encodeDevice/search", null, pageNo, pageSize));
}
@ApiOperation(value = "2-查询摄像头视频流", notes = "调用海康威视接口查询摄像头视频流")
@GetMapping("/cameraPreviewUrl")
public Response cameraPreviewUrl(String cameraCode) {
return R