敏感词判断接口一个很奇怪的问题,msgSecCheck,总是返回 0,原因未知?
完整代码如下: log.info("微信敏感词判断,令牌:{} 内容:{}",access_token,content); try { Map<String, Object> params = new HashMap<>(); params.put("content", content); //参数 CloseableHttpClient httpClient = HttpClientBuilder.create().build(); String url = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=ACCESS_TOKEN"; url = StringUtils.replace(url, "ACCESS_TOKEN", access_token); HttpPost httpPost = new HttpPost( url ); // 接口 httpPost.addHeader(HTTP.CONTENT_TYPE, "application/json"); String body = JSON.toJSONString(params); //必须是json模式的 post log.info("请求微信服务器敏感词检查:{}",body); StringEntity entity = new StringEntity(body); httpPost.setEntity(entity); HttpResponse response = httpClient.execute(httpPost); InputStream inputStream = response.getEntity().getContent(); BufferedReader in = new BufferedReader(new InputStreamReader(inputStream,"utf-8")); String line; String message = ""; while ((line = in.readLine()) != null) { message += line; } log.info("微信服务器敏感词检查接口:{}",message); String errcode = takeString(message,"errcode"); if(StringUtil.isBlank(errcode) || Integer.parseInt(errcode)==0) { //无敏感词 return ""; } else if(errcode.compareTo("44002")==0) { //令牌失效 this.accessTokenSave(""); return ("微信访问令牌失效,请重新再试"); } else if(errcode.compareTo("87014")==0) { return "包含敏感词信息"; } else { return errcode; } } catch(Exception e) { e.printStackTrace(); return "接口错误:" + e.getMessage(); } 测试数据和结果如下: 请求微信服务器敏感词检查:{"content":"特3456书yuuo莞6543李zxcz蒜7782法fgnv级"} 微信服务器敏感词检查接口:{"errcode":0,"errmsg":"ok"} 无论我如何改变关键词,结果都是0,肯定是接口调用无效,但是又没有明确的错误信息,这样导致小程序无法上线,实在坑的冤枉啊!