网站建设页面设计公司网站时什么是重要的

张小明 2026/1/13 0:36:47
网站建设页面,设计公司网站时什么是重要的,微博网站开发,深圳住房和城乡建设局网站首页1. 前言#xff1a; artemis-http-client sdk 中提供获取门禁事件图片的方法#xff0c;但实际图片访问地址为该响应的重定向地址 问题来了#xff1a;虽然他提供了 sdk #xff0c;但没有办法通过 sdk 获取重定向的地址于是产生了本文#xff0c;自己通过hutools的 httpU…1. 前言artemis-http-clientsdk 中提供获取门禁事件图片的方法但实际图片访问地址为该响应的重定向地址问题来了虽然他提供了 sdk 但没有办法通过 sdk 获取重定向的地址于是产生了本文自己通过hutools的 httpUtil调用2. 签名工具类HikSignUtil 记得先引入一下 artemis-http-clientpackagecom.lxsy.util;importcn.hutool.core.codec.Base64;importcn.hutool.crypto.digest.DigestUtil;importcn.hutool.crypto.digest.HMac;importcn.hutool.crypto.digest.HmacAlgorithm;importjava.nio.charset.StandardCharsets;importjava.time.ZoneOffset;importjava.time.ZonedDateTime;importjava.time.format.DateTimeFormatter;importjava.util.HashMap;importjava.util.Map;/** * 海康 OpenAPI 签名工具类 * 签名算法HmacSHA256 Base64 */publicclassHikSignUtil{privatestaticfinalDateTimeFormatterRFC_1123_FORMATTERDateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneOffset.UTC);/** * 生成请求头包含签名 * * param appKey 应用Key * param appSecret 应用Secret * param url 请求的相对路径如 /artemis/api/acs/v1/event/pictures * param body 请求体JSON字符串 * return 包含签名的请求头Map */publicstaticMapString,StringbuildHeaders(StringappKey,StringappSecret,Stringurl,Stringbody){// Content-MD5请求体的MD5值Base64编码StringcontentMd5Base64.encode(DigestUtil.md5(body));// Date 头RFC1123StringdateRFC_1123_FORMATTER.format(ZonedDateTime.now(ZoneOffset.UTC));// 签名字符串拼接// httpHeaders HTTP METHOD \n Accept \n Content-MD5 \n Content-Type \n Date \n// customHeaders x-ca-key : appKey \n// signString httpHeaders customHeaders urlStringBuildersignBuildernewStringBuilder();signBuilder.append(POST).append(\n);// HTTP METHODsignBuilder.append(*/*).append(\n);// AcceptsignBuilder.append(contentMd5).append(\n);// Content-MD5signBuilder.append(application/json).append(\n);// Content-TypesignBuilder.append(date).append(\n);// DatesignBuilder.append(x-ca-key:).append(appKey).append(\n);// customHeaderssignBuilder.append(url);// urlStringsignStringsignBuilder.toString();// 使用 HmacSHA256 算法计算签名HMachmacnewHMac(HmacAlgorithm.HmacSHA256,appSecret.getBytes(StandardCharsets.UTF_8));StringsignatureBase64.encode(hmac.digest(signString));// 构建请求头MapString,StringheadersnewHashMap();headers.put(Accept,*/*);headers.put(Content-Type,application/json);headers.put(Content-MD5,contentMd5);headers.put(Date,date);headers.put(x-ca-key,appKey);headers.put(x-ca-signature,signature);headers.put(x-ca-signature-headers,x-ca-key);returnheaders;}}3. 使用示例1protectedstaticfinalArtemisConfigartemisConfignewArtemisConfig(192.XX.13.XX:443,123,123);/** * 使用自建 HttpClient 调用海康接口便于排查网络/签名问题 */publicstaticPageResponseResultEventInfoDtogetEventListWithHttpClient(EventsRequesteventsRequest)throwsException{if(eventsRequestnull){eventsRequestnewEventsRequest();}Stringurl/artemis/api/acs/v2/door/events;StringfullUrlhttps://artemisConfig.getHost()url;StringbodyJSON.toJSONString(eventsRequest);MapString,StringheadersHikSignUtil.buildHeaders(artemisConfig.getAppKey(),artemisConfig.getAppSecret(),url,body);try(CloseableHttpClienthttpClientcreateHttpClient(false)){HttpPosthttpPostnewHttpPost(fullUrl);headers.forEach(httpPost::setHeader);httpPost.setEntity(newStringEntity(body,ContentType.APPLICATION_JSON));try(CloseableHttpResponseresponsehttpClient.execute(httpPost)){intstatusresponse.getStatusLine().getStatusCode();StringrespBodyresponse.getEntity()null?null:EntityUtils.toString(response.getEntity());if(statusHttpStatus.SC_OK){returncheckResp(respBody,newTypeReferencePageResponseResultEventInfoDto(){});}thrownewException(获取事件列表失败状态码: status, 响应: respBody);}}}示例2protectedstaticfinalArtemisConfigartemisConfignewArtemisConfig(192.XX.13.XX:443,123,123);publicstaticStringpictures(StringsvrIndexCode,StringpicUri)throwsException{Stringurl/artemis/api/acs/v1/event/pictures;StringfullUrlhttps://artemisConfig.getHost()url;// 构建请求体PicturesRequestrequestnewPicturesRequest(svrIndexCode,picUri);StringbodyJSON.toJSONString(request);// 使用签名工具生成请求头MapString,StringheadersHikSignUtil.buildHeaders(artemisConfig.getAppKey(),artemisConfig.getAppSecret(),url,body);try(CloseableHttpClienthttpClientcreateHttpClient(false)){HttpPosthttpPostnewHttpPost(fullUrl);headers.forEach(httpPost::setHeader);httpPost.setEntity(newStringEntity(body,ContentType.APPLICATION_JSON));try(CloseableHttpResponseresponsehttpClient.execute(httpPost)){intstatusresponse.getStatusLine().getStatusCode();if(statusHttpStatus.SC_MOVED_TEMPORARILY||statusHttpStatus.SC_MOVED_PERMANENTLY||statusHttpStatus.SC_SEE_OTHER||statusHttpStatus.SC_TEMPORARY_REDIRECT||statusHTTP_STATUS_PERMANENT_REDIRECT){HeaderlocationHeaderresponse.getFirstHeader(Location);if(locationHeader!nullStrUtil.isNotBlank(locationHeader.getValue())){returnlocationHeader.getValue();}thrownewException(302重定向但未获取到Location头);}StringrespBodyresponse.getEntity()null?null:EntityUtils.toString(response.getEntity());thrownewException(获取图片失败状态码: status, 响应: respBody);}}}
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

网站推广工作总结500万在北京几环买房

Xiaomusic终极安装指南:5分钟让小爱音箱变身智能音乐中心 【免费下载链接】xiaomusic 使用小爱同学播放音乐,音乐使用 yt-dlp 下载。 项目地址: https://gitcode.com/GitHub_Trending/xia/xiaomusic Xiaomusic是一个专为小爱音箱设计的开源音乐播…

张小明 2026/1/10 11:58:45 网站建设

大连网站建设意动科技公司情侣博客网站模板下载

如何高效抓取淘宝直播弹幕数据:完整实战指南 【免费下载链接】taobao-live-crawler A crawler on taobao live barrages. 项目地址: https://gitcode.com/gh_mirrors/ta/taobao-live-crawler 想要了解淘宝直播间里观众的真实想法吗?想通过弹幕数据…

张小明 2026/1/9 2:06:12 网站建设

淘宝哪些做网站关键词排名的有用吗100块钱开发网站

如果 SerDes 这么厉害,为什么不能用它把所有接口(内存、显卡、Chiplet)都统一了? 答案是:物理层(PHY)并没有你想象中那么“通用”。 虽然它们都可能用到 SerDes 技术,但就像F1 赛车、…

张小明 2026/1/12 0:59:32 网站建设

泗阳做网站免费的舆情网站入口在哪

3倍性能提升!COLMAP三维重建的矩阵运算优化实战 【免费下载链接】colmap COLMAP - Structure-from-Motion and Multi-View Stereo 项目地址: https://gitcode.com/GitHub_Trending/co/colmap COLMAP作为业界领先的三维重建工具,其核心计算性能直接…

张小明 2025/12/24 8:05:21 网站建设

h5移动网站开发国外网站设计模板

第一阶段 总体数据与功能设计规划第一部分:整体架构与关键子系统1. 系统架构概览Linux显示子系统层次结构: ├── V4L2 (Video for Linux 2)子系统 │ ├── 视频采集层 (MIPI-CSI摄像头) │ ├── 视频缓冲区管理 │ └── 视频格式转换 ├─…

张小明 2025/12/31 15:16:43 网站建设