当前位置:网站首页>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;
}边栏推荐
- GCC基础知识
- Office提示系统配置无法运行怎么办?
- Implementation of flutter gesture monitoring and Sketchpad
- Data Lake: spark, a distributed open source processing engine
- Configure st-gcn environment record [Google lab]
- IOS interview preparation - IOS
- Numpy basic learning
- 正确的用户拖拽方式
- Use openmap and ArcGIS to draw maps and transportation networks of any region, and convert OMS data into SHP format
- IOS interview preparation - Objective-C
猜你喜欢

Classes and objects (II)

Use jupyter (2) to establish shortcuts to open jupyter and common shortcut keys of jupyter

un7.28:redis客户端常用命令。

Flutter 手势监听和画板实现

命令行交互工具(最新版) inquirer 实用教程

Excel卡住了没保存怎么办?Excel还没保存但是卡住了的解决方法

1 sentence of code, get asp Net core binds multiple sources to the same class

正确的用户拖拽方式

央企建筑企业数字化转型核心特征是什么?

File operation (Advanced C language)
随机推荐
新产品上市最全推广方案
Recommendation system of online education
Mysql:the user specified as a definer ('root '@'%) does not exist
Review key points and data sorting of information metrology in the second semester of 2022 (teacher zhaorongying of Wuhan University)
学术 | [LaTex]超详细Texlive2022+Tex Studio下载安装配置
UE plays video in scene or UMG
EMI interference troubleshooting with near-field probe and current probe
央企建筑企业数字化转型核心特征是什么?
Opencv environment construction
IOS interview preparation - Objective-C
Recyclerview switches the focus up and down through the dpad key. When switching to the control outside the interface, the focus will jump left and right
Makefile(make)常见规则(二)
正确的用户拖拽方式
2022杭电多校联赛第四场 题解
Box horizontal vertical center layout (summary)
New year's greetings from programmers
【无标题】
Stack and queue and priority queue (large heap and small heap) simulation implementation and explanation of imitation function
[c language] PTA 7-63 falling ball
Classes and objects (III)