From 63f35ddddcda0a0f1fd99091fbf3eeb32e414ba6 Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Fri, 08 Jan 2021 00:31:40 +0800 Subject: [PATCH] 公众号模板消息demo --- zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo.java | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo.java b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo.java index f0757e4..e5c650d 100644 --- a/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo.java +++ b/zq-erp/src/main/java/com/matrix/system/wechart/templateMsg/MsgDemo.java @@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSONObject; import com.matrix.component.tools.HttpClientUtil; import com.matrix.core.pojo.AjaxResult; +import com.matrix.system.hive.plugin.util.HttpUtils; import com.matrix.system.shopXcx.api.WeChatGzhApiTools; import com.matrix.system.shopXcx.bean.ShopAdvertisType; import org.apache.commons.httpclient.HttpClient; @@ -36,15 +37,19 @@ @ResponseBody public AjaxResult template() { GzhTemplateMessagePojo messagePojo=new GzhTemplateMessagePojo(); - messagePojo.setTouser("123"); - messagePojo.setTemplate_id("543"); - messagePojo.setUrl("231"); - messagePojo.setMiniprogram("65475234","/123/234123412"); - messagePojo.setFirst("1231","#453454"); - messagePojo.setKeyWord("1231","#453454"); - System.out.println(JSONObject.toJSON(messagePojo).toString()); + messagePojo.setTouser("o8EB656NQYwhUuKPMhVVwP_wtLJI"); + messagePojo.setTemplate_id("Mqu9xPYj_JFhXNj7nLJS7LESQUy6Z7FoCOmVO66Oxe8"); + //messagePojo.setUrl("www.baidu.com"); + // messagePojo.setMiniprogram(gzhAppId,"/123/234123412"); + messagePojo.setFirst("尊敬的谭娅:","#453454"); + messagePojo.setKeyWord("活细胞肩部护理","#453454"); + messagePojo.setKeyWord("2014年7月21日 18:36","#453454"); + messagePojo.setRemark("您的护理课程剩余3次。","#453454"); + String ACCESS_TOKEN=WeChatGzhApiTools.getAccessToken(gzhAppId,gzhSecret); String url="https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+ACCESS_TOKEN; + + System.out.println(JSONObject.toJSON(messagePojo).toString()); JSONObject result= HttpClientUtil.sendPostWithJson(url,JSONObject.toJSON(messagePojo).toString()); System.out.println(result.toString()); return AjaxResult.buildSuccessInstance("1"); @@ -52,4 +57,21 @@ } + + @RequestMapping("/getUserList") + @ResponseBody + public AjaxResult getUserList() { + + String ACCESS_TOKEN=WeChatGzhApiTools.getAccessToken(gzhAppId,gzhSecret); + + String url="https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID".replaceAll("ACCESS_TOKEN",ACCESS_TOKEN); + + + String result= HttpUtils.sendGet(url,""); + System.out.println(result.toString()); + return AjaxResult.buildSuccessInstance("1"); + + + } + } -- Gitblit v1.9.1