当前位置:网站首页>Wechat picture identification
Wechat picture identification
2022-07-29 04:53:00 【BIG_ PEI】
for (String url : worksRelease.getWorksImg()) {
try {
// Picture verification
WxCheckDomain wxCheckDomain = weixinService.mediaCheckAsync(UrlToMultipartFile.urlToMultipartFile(url));
if (wxCheckDomain.getErrCode()!=0) {
throw new EnException(ResultCode.PARAM_ERROR.getCode(), " The content contains illegal content ");
}
} catch (Exception e) {
throw new EduServiceException(e.getMessage());
} }
/**
* Verify picture
*
* @param multipartFile
*/
public WxCheckDomain mediaCheckAsync(MultipartFile multipartFile) {
WxCheckDomain wxCheckDomain = new WxCheckDomain();
try {
String accToken = getWxxcxAccToken();
Integer code = reCheckPic(multipartFile, accToken);
System.err.println(code);
if (code != 0) {
wxCheckDomain.setErrCode(code);
throw new EmptyException(" The content contains illegal content ");
}
wxCheckDomain.setErrCode(code);
} catch (Exception e) {
e.printStackTrace();
}
return wxCheckDomain;
} /**
* Get wechat applet accToken
*
* @return
*/
public String getWxxcxAccToken() {
String accToken = "";
try {
//redis obtain token
if (redisClient.get(artwork_WXXCX_ACCTOKEN) == null) {
Call<Map<String, Object>> call = wxxcxEndPoint.cBToken("client_credential", wxxcxConfig.getAppId(), wxxcxConfig.getSecret());
Map<String, Object> map = call.execute().body();
accToken = (String) map.get("access_token");
redisClient.set(artwork_WXXCX_ACCTOKEN, accToken);
redisClient.expire(artwork_WXXCX_ACCTOKEN, 7200);
System.err.println(accToken);
} else {
accToken = redisClient.get(artwork_WXXCX_ACCTOKEN);
System.err.println(accToken);
}
} catch (Exception e) {
e.printStackTrace();
}
return accToken;
}边栏推荐
- excel怎么设置行高和列宽?excel设置行高和列宽的方法
- MySQL time calculation function
- Command line interactive tools (latest version) inquirer practical tutorial
- File operation (Advanced C language)
- Classes and objects (I)
- 如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
- Auto.js脚本开发入门
- Makefile(make)常见规则(二)
- Use jupyter (2) to establish shortcuts to open jupyter and common shortcut keys of jupyter
- mujoco和mujoco_py安装以及解决libXcursor.so.1:NO such dictionary
猜你喜欢
随机推荐
Common rules of makefile (make) (II)
Nail dialog text converted to pictures cannot be copied and pasted on the document
ssm整合增删改查
LeetCode(剑指 Offer)- 53 - I. 在排序数组中查找数字 I
钉钉对话框文子转换成图片 不能复制粘贴到文档上
EF core: one to one, many to many configuration
SSM integration, addition, deletion, modification and query
网络之以太网
搭建手机APP需要用到什么服务器
Makefile+Make基础知识
带你搞懂 Kubernetes 集群中几种常见的流量暴露方案
Box horizontal vertical center layout (summary)
Tower of Hanoi classic recursion problem (C language implementation)
Ethernet of network
Introduction to auto.js script development
[C language] PTA 7-47 binary leading zero
Implementation of flutter gesture monitoring and Sketchpad
WPS如何进行快速截屏?WPS快速截屏的方法
iOS面试准备 - 其他篇
IOS interview preparation - Online









