URI uri = new URI("https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + token);HttpPost httpPost = new HttpPost(uri);
httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json;charset=UTF-8");
Map resquestObj = new HashMap<>();
resquestObj.put("content",query);
resquestObj.put("version",2);
resquestObj.put("scene", 3);
resquestObj.put("openid", openid);
String jsonStr = JSONUtil.toJsonStr(resquestObj);
StringEntity entity = new StringEntity(jsonStr, Charset.forName("UTF-8"));
// 设置编码格式
entity.setContentEncoding("UTF-8");
// 发送Json格式的数据请求
entity.setContentType("application/json");
// 创建HTTP客户端,并使用Scanner读取SSE流式数据
CloseableHttpClient httpClient = HttpClients.custom().build();
String response = "";
try {
httpPost.setEntity(entity);
HttpEntity entity1 = httpClient.execute(httpPost).getEntity();
response = EntityUtils.toString(entity1);
}finally {
// 关闭Scanner和HTTP客户端
httpClient.close();
}
JSONObject entries = JSONUtil.parseObj(JSONUtil.parseObj(response).get("result"));
System.err.println(entries.get("suggest"));
//这里的结果永远都是pass
return "pass".equals(entries.get("suggest").toString());
你好,请提供具体的traceid,以便进行后续核实
解决了吗