收藏
回答

java使用httpPost调用敏感词msg_sec_check无效, result永远是pass?

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());


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

2 个回答

  • 小程序社区运营-wetingtu
    小程序社区运营-wetingtu
    2023-06-21

    你好,请提供具体的traceid,以便进行后续核实

    2023-06-21
    有用
    回复 1
    • 天生袁皓天
      天生袁皓天
      2023-10-16
      是管理员吗
      2023-10-16
      回复
  • 天生袁皓天
    天生袁皓天
    2023-10-16

    解决了吗

    2023-10-16
    有用
    回复
登录 后发表内容