小程序
小游戏
企业微信
微信支付
扫描小程序码分享
是否有在小程序java调用图片风险检测的例子
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
你好,可以参考下这个https://developers.weixin.qq.com/community/develop/article/doc/00008ecf79c44895b379cbd145b013
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
@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; }
解决了就是涉黄图片不好找
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
你好,可以参考下这个https://developers.weixin.qq.com/community/develop/article/doc/00008ecf79c44895b379cbd145b013
@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; }
解决了就是涉黄图片不好找