|
@@ -29,11 +29,11 @@ public class WeChatMessage {
|
|
private static final String secret= "cf69d556bbc962fa60a59b0fece3fa95";
|
|
private static final String secret= "cf69d556bbc962fa60a59b0fece3fa95";
|
|
private static final String templateId= "w95K45G9-2xGocleqrtGoHwEGF6ocqSu8EbDBxCQSR0";
|
|
private static final String templateId= "w95K45G9-2xGocleqrtGoHwEGF6ocqSu8EbDBxCQSR0";
|
|
|
|
|
|
- public void sendMsg(String deviceCode,String warningContent, Date uploadDate,String location,String openId){
|
|
|
|
|
|
+ public void sendMsg(String deviceName,String deviceCode,String warningContent, Date uploadDate,String location,String openId){
|
|
//1:获取token(接口调用凭证)
|
|
//1:获取token(接口调用凭证)
|
|
String token = queryToken();
|
|
String token = queryToken();
|
|
//2:发送订阅消息
|
|
//2:发送订阅消息
|
|
- send(token,warningContent,deviceCode,uploadDate,location,openId);
|
|
|
|
|
|
+ send(token,deviceName,warningContent,deviceCode,uploadDate,location,openId);
|
|
}
|
|
}
|
|
|
|
|
|
// 1: 获取 access_token (2h过期)
|
|
// 1: 获取 access_token (2h过期)
|
|
@@ -47,7 +47,7 @@ public class WeChatMessage {
|
|
return token;
|
|
return token;
|
|
}
|
|
}
|
|
|
|
|
|
- public void send(String token,String warningContent,String deviceCode, Date uploadDate,String location,String openId){
|
|
|
|
|
|
+ public void send(String token,String deviceName,String warningContent,String deviceCode, Date uploadDate,String location,String openId){
|
|
String msgUrl="https://api.weixin.qq.com/cgi-bin/message/subscribe/send";
|
|
String msgUrl="https://api.weixin.qq.com/cgi-bin/message/subscribe/send";
|
|
msgUrl = msgUrl + "?access_token=" + token;
|
|
msgUrl = msgUrl + "?access_token=" + token;
|
|
// 设置模板参数
|
|
// 设置模板参数
|
|
@@ -58,7 +58,7 @@ public class WeChatMessage {
|
|
// 设置data 模板内容
|
|
// 设置data 模板内容
|
|
HashMap<String, Object> data = new HashMap<>();
|
|
HashMap<String, Object> data = new HashMap<>();
|
|
//报警设备
|
|
//报警设备
|
|
- data.put("thing1", formatParam(deviceCode));
|
|
|
|
|
|
+ data.put("thing1", formatParam(deviceName));
|
|
//报警类型
|
|
//报警类型
|
|
data.put("thing2", formatParam(warningContent));
|
|
data.put("thing2", formatParam(warningContent));
|
|
//报警时间
|
|
//报警时间
|