ResponseData : {"errcode":0,"errmsg":"ok","trace_id":"645afea0-76a6d9aa-3ad43c68"},服务器是配置成功的,配了url,taken,和EncodingAESKey选的是兼容模式,数据格式选的是json 麻烦帮忙查一下这个trace_id的状态
获取trace_id接口
public ObjectResponseModel imgSecCheck2(@RequestBody @Valid ImgSecCheckRequest request) throws Exception {
String appId =null;
String secret=null;
MiniAppParameterEntity miniAppParameterEntity = new MiniAppParameterEntity();
miniAppParameterEntity.setBrandId(request.getBrandId());
MiniAppParameterEntity obj =
miniAppParameterServiceImpl.selectMiniAppParameterByBrandId(miniAppParameterEntity);
if (Objects.nonNull(obj)) {
appId = obj.getAppId();
secret = obj.getSecret();
}
ResponseUtils.checkParamNull(appId, "appId");
ObjectResponseModel response = new ObjectResponseModel();
WechatConfigEntity entity = new WechatConfigEntity();
entity.setAppId(appId);
entity.setSecret(secret);
entity.setWxType("qrcode_xcx_access_token");
WechatResponse wechat = getWxToken(entity);
String accessToken = wechat.getAccess_token();
HashMap params = new HashMap<>();
String imgSecCheckUrl = wechatConfig.getImgSecCheck2() + accessToken;
params.put("media_url", request.getMediaUrl());
params.put("media_type", 2);
params.put("version", 2);
params.put("scene", 1);
params.put("openid", request.getOpenid());
logger.info("开始调微信api进行图片安全内容检测:" + DateUtils.getCurrentTime());
String post = restTemplateUtils.post(imgSecCheckUrl, params, String.class);
JSONObject jsonObject = JSON.parseObject(post);
String trace_id = jsonObject.getString("trace_id");
logger.info("调微信api进行图片安全内容检测结束:" + DateUtils.getCurrentTime() + ",结果为:" + ObjectUtils.objectParseJsonStr(trace_id));
response.setSingle(trace_id);
return response;
}
接受腾讯推送数据接口(配置接口)
public String receiveImgSecCheck(HttpServletRequest request) throws Exception {
logger.info("腾讯回调数据时间:"+System.currentTimeMillis());
ValueOperations valueOperations = cacheTemplate.getRedisTemplate().opsForValue();
valueOperations.set(System.currentTimeMillis()+"_"+"receiveImgSecCheckGet",JSON.toJSONString(request));
boolean isGet = request.getMethod().equalsIgnoreCase("GET");
if (isGet){
String signature = request.getParameter("signature");
String timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");
String echostr = request.getParameter("echostr");
String[] array = new String[] { token, timestamp, nonce};
StringBuffer sb = new StringBuffer();
// 字符串排序
Arrays.sort(array);
for (int i = 0; i < 3; i++) {
sb.append(array[i]);
}
String sortStr = sb.toString();
String sha1Hex = DigestUtils.sha1Hex(sortStr);
if (signature.equals(sha1Hex)){
return echostr;
}else {
return null;
}
}
BufferedReader streamReader = new BufferedReader( new InputStreamReader(request.getInputStream(), "UTF-8"));
StringBuilder responseStrBuilder = new StringBuilder();
String inputStr;
while ((inputStr = streamReader.readLine()) != null){
responseStrBuilder.append(inputStr);
}
JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
String param= jsonObject.toJSONString();
logger.info("转出来的数据:"+param);
String key = "Tencent:imgSecCheck:"+jsonObject.getString("trace_id");
valueOperations.set(key,param,5, TimeUnit.MINUTES);
return "success";
}
提供get和post代码截图看看
请问这个配置开放post接受模式是指代码层面的,还是说手动配置接口的时候配置的,我现在是代码层面兼容了get和post,是手动配置的时候需要配置其他的吗