[图片]
求助 消息模版中传中文一直乱码,如何解决?代码如下: public static void main(String[] args) { String token =WeiXinUtils.getAccessToken(); System.out.println("token = "+token); // 组装要发送的数据 JSONObject body = new JSONObject(); // 要推给谁 body.put("touser", "xxxx"); // 模板ID body.put("template_id", "xxxx"); JSONObject data = new JSONObject(); JSONObject data1 = new JSONObject(); data1.put("value", "当天12点"); data.put("character_string1", data1); body.put("data", data); System.out.println("data = "+body.toString()); String post = ""; try { post = HttpClientUtils.sendPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token, body.toString()); }catch (Exception e){ System.out.println("eeee = "+e); } System.out.println("post = "+post); } public static String sendPost(String url, String data) throws Exception { URL fullUrl = new URL(url); HttpURLConnection connection = (HttpURLConnection) fullUrl.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Accept", "application/json"); connection.setRequestProperty("Charset", "UTF-8"); connection.setRequestProperty("Content-Length", String.valueOf(data.length())); connection.setDoOutput(true); DataOutputStream wr = new DataOutputStream(connection.getOutputStream()); wr.writeBytes(data); wr.flush(); wr.close(); if (connection.getResponseCode()!= 200) { throw new RuntimeException("Failed : HTTP error code : " + connection.getResponseCode()); } BufferedReader br = new BufferedReader(new InputStreamReader((connection.getInputStream()))); StringBuilder sb = new StringBuilder(); String output; while ((output = br.readLine())!= null) { sb.append(output); } connection.disconnect(); return sb.toString(); } y已经设置了 utf-8 还是显示乱码,请教下如何解决
07-17我这里 也是 一直在报错 {"errcode":47001,"errmsg":"data format error rid: 668f6817-74c18a87-4b126288"} 数据格式如下: {"character_string2":{"value":"aaa"},"const2":{"value":"审核通过"}} 大佬们帮忙看下
公众号的枚举值如何传值 我这样传报枚举值格式有误?[图片][图片]
07-11