@PostMapping("/imgSecCheck2") @ApiOperation(value = "图片内容判断", notes = "") public CommonResponse<OpenIdVO> imgSecCheck2( @ApiParam(name = "file", value = "file", required = true) @RequestParam("file") MultipartFile file, @ApiParam(name = "access_token", value = "access_token", required = true) @RequestParam String access_token ) throws IOException { String url = "https://api.weixin.qq.com/wxa/img_sec_check?access_token=" + access_token; log.info("检验图片安全入参:{}", access_token); byte[] bytes = file.getBytes(); HttpHeaders headers2 = new HttpHeaders(); headers2.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE); ResponseEntity<String> responseEntity = restTemplateHttps.postForEntity(url, new HttpEntity<>(bytes, headers2), String.class); log.info("检验图片安全出参:{}", responseEntity); HttpStatus statusCode = responseEntity.getStatusCode(); CommonResponse<OpenIdVO> resp = new CommonResponse<>(); if (statusCode.value() == 200) { String bodyString = responseEntity.getBody(); JSONObject body = JSONObject.parseObject(bodyString); Integer errcode = body.getInteger("errcode"); String errmsg = body.getString("errmsg"); if (errcode == 0) { resp.setMsg(errmsg); } else { resp.error(errcode, errmsg); } } else { resp.error(RespErrorCode.SERVICE_ERROR, "图片内容判断失败"); } return resp; } [图片] 解决了就是涉黄图片不好找
你好是否有在小程序java调用图片风险检测的例子?是否有在小程序java调用图片风险检测的例子
2021-04-14