|
|
@ -27,6 +27,33 @@ public class WxMessage { |
|
|
|
mp_template_msg.put("template_id", template_id);// 模板Id
|
|
|
|
mp_template_msg.put("url", ""); // 点击模板信息跳转地址
|
|
|
|
|
|
|
|
Map<String, String> miniprogram = new HashMap<>(); |
|
|
|
miniprogram.put("appid", WxConfig.MP_APPID); |
|
|
|
miniprogram.put("pagepath", pagepath); |
|
|
|
mp_template_msg.put("miniprogram", miniprogram); |
|
|
|
|
|
|
|
Map<String, TemplateDataValue> sendData = new HashMap<>(); |
|
|
|
data.forEach((key, val) -> { |
|
|
|
sendData.put(key, new TemplateDataValue(val)); |
|
|
|
}); |
|
|
|
mp_template_msg.put("data", sendData); |
|
|
|
|
|
|
|
sendBody.put("mp_template_msg", mp_template_msg); |
|
|
|
ResponseEntity<RespMessReturn> forEntity = new RestTemplate().postForEntity(wxUrl, sendBody, RespMessReturn.class); |
|
|
|
return forEntity.getBody(); |
|
|
|
} |
|
|
|
public static RespMessReturn sendMessages(String template_id, String touser, String pagepath, Map<String, String> data) { |
|
|
|
String wxUrl = MP_URL_MESSAGE_SEND.replace("ACCESS_TOKEN", WxConfig.mpAccessToken()); |
|
|
|
|
|
|
|
Map<String, Object> sendBody = new HashMap<>(); |
|
|
|
sendBody.put("touser", touser); |
|
|
|
|
|
|
|
//拼接base参数
|
|
|
|
Map<String, Object> mp_template_msg = new HashMap<>(); |
|
|
|
mp_template_msg.put("appid", WxConfig.WX_APPID); |
|
|
|
mp_template_msg.put("template_id", template_id);// 模板Id
|
|
|
|
mp_template_msg.put("url", ""); // 点击模板信息跳转地址
|
|
|
|
|
|
|
|
// Map<String, String> miniprogram = new HashMap<>();
|
|
|
|
// miniprogram.put("appid", WxConfig.MP_APPID);
|
|
|
|
// miniprogram.put("pagepath", pagepath);
|
|
|
@ -42,7 +69,6 @@ public class WxMessage { |
|
|
|
ResponseEntity<RespMessReturn> forEntity = new RestTemplate().postForEntity(wxUrl, sendBody, RespMessReturn.class); |
|
|
|
return forEntity.getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 向多个用户推送同一模板消息 |
|
|
|
* |
|
|
|