public static String sendMessage(String xml, String urlpath) { String msg = ""; OutputStreamWriter wr = null; BufferedReader rd = null; HttpURLConnection conn = null; try { URL url = new URL(urlpath); conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(10000); conn.setReadTimeout(10000); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); conn.setRequestProperty("Accept-Charset", "utf-8"); wr = new OutputStreamWriter(conn.getOutputStream(), "utf-8"); wr.write(xml); wr.flush(); rd = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); String line; while ((line = rd.readLine()) != null) { msg = msg + line; } } catch (Exception e) { e.printStackTrace(); } finally { try { if (wr != null) wr.close(); if (rd != null) rd.close(); if (conn != null) conn.disconnect(); } catch (Exception e) { } } return msg; } 用上面的代码可以了,我之前遇到这个问题,
模板消息接口调用返回成功ok,却收不到服务通知- 当前 Bug 的表现(可附上截图) - 预期表现 - 复现路径 - 提供一个最简复现 Demo 接口调用数据: {"data":{"keyword1":{"value":"12"},"keyword2":{"value":"2019-05-18 19:55"},"keyword3":{"value":"23"}},"form_id":"4f904885916944d587c19cb8c6b04440","messageType":0,"page":"pages/detail/detail?troubleId=2","template_id":"V0KeA1QZRFSY6R6PtKvy-LwMWMYZ443_EYy6xsNSnDo","touser":"oixGf4kMBUXcjnmMIhIGqD5J2oHg"}
2019-09-27我也遇到同样的问题,真是吐血,用main方法没问题,一到程序里面就不行了问题返回也是正常的
小程序的服务通知,接口返回成功状态,但收不到调用小程序服务通知接口 https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN 返回值为 {"errcode":0,"errmsg":"ok"} 但是用户一直收不到消息推送。 -------- APPID:wx99418b7b5cdcc4d4 模板ID:LVzECqn8axDbo8f6ZEUp5u23c63uQWHUFgKL14ZWQ6k
2019-09-27