收藏
回答

图片安全内容检测接口java调用出现47001?

// 腾讯API检测涉黄

CloseableHttpClient httpclient = HttpClients.createDefault();

CloseableHttpResponse response = null;

String appId = ResourceUtil.getConfigByName("wx.appId");

String appSecret = ResourceUtil.getConfigByName("wx.secret");

String accessToken = WX_TokenUtil.getWXToken(appId, appSecret).getAccessToken();

HttpPost request = new HttpPost("https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + accessToken);

request.addHeader("Content-Type", "application/octet-stream");

try {

byte[] buffer = file.getBytes();

request.setEntity(new ByteArrayEntity(buffer, ContentType.create("image/jpg")));

response = httpclient.execute(request);

HttpEntity entity = response.getEntity();

String result = EntityUtils.toString(entity, "UTF-8");// 转成string

JSONObject obj1 = JSONObject.parseObject(result);

int errorcode = (int) obj1.get("errcode");

if (errorcode != 0) {

return "error1";

} catch (Exception e) {

System.out.println("错误");

代码一直提示47001问题,有没有好点的解决方案

回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签