微信小程序的订阅消息

编程入门 行业动态 更新时间:2024-10-10 07:28:28

微信小程序的订阅<a href=https://www.elefans.com/category/jswz/34/1771421.html style=消息"/>

微信小程序的订阅消息

官网文档

String postUrl ="="+accesstoken;
com.alibaba.fastjson.JSONObject jsonObject = new JSONObject();jsonObject.put("touser", openid);   // openidjsonObject.put("template_id", templateId);jsonObject.put("page", page);JSONObject data = new JSONObject();JSONObject thing1 = new JSONObject();thing1.put("value", typeStr);//服务标题JSONObject time2 = new JSONObject();time2.put("value", DateUtils.getTime());//服务时间JSONObject phrase3 = new JSONObject();phrase3.put("value", handle);//服务进度JSONObject thing4 = new JSONObject();thing4.put("value", remark);//备注data.put("thing6",thing1);data.put("time4",time2);data.put("thing3",phrase3);data.put("thing5",thing4);jsonObject.put("data", data);jsonObject.put("miniprogram_state", "trial");//跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版String string = HttpClientUtils.sendPostJsonStr(postUrl, jsonObject.toJSONString());com.alibaba.fastjson.JSONObject result = com.alibaba.fastjson.JSON.parseObject(string);

 public static String sendPostJsonStr(String url, String jsonString) throws IOException {if (jsonString == null || jsonString.isEmpty()) {return sendPost(url);}String resp = "";StringEntity entityStr = new StringEntity(jsonString,ContentType.create("text/plain", "UTF-8"));CloseableHttpClient httpClient = HttpClients.createDefault();HttpPost httpPost = new HttpPost(url);httpPost.setEntity(entityStr);CloseableHttpResponse response = null;try {response = httpClient.execute(httpPost);HttpEntity entity = response.getEntity();resp = EntityUtils.toString(entity, "UTF-8");EntityUtils.consume(entity);} catch (ClientProtocolException e) {log.error(e.getMessage());} catch (IOException e) {log.error(e.getMessage());} finally {if (response != null) {try {response.close();} catch (IOException e) {log.error(e.getMessage());}}}if (resp == null || resp.equals("")) {return "";}return resp;}

更多推荐

微信小程序的订阅消息

本文发布于:2024-03-13 18:52:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1734597.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   程序   微信小

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!