获取发送模板
获取手机号和openid
参考 无极低码:微信小程序获取用户手机号码的详细步骤前端后台
订阅消息
String tk=WeixinUtil.getAccessToken().getToken();
String url="https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+tk;
Map<String, Object> map = new HashMap<String, Object>();
map.put("template_id", template_id);
map.put("touser", openid);
Map<String, Object> m1,m2 ,m3;
m1 = new HashMap<String, Object>();
m1.put("value", "天气提醒,你哈哈哦");
m2 = new HashMap<String, Object>();
m2.put("value", "今天天气很棒哦");
m3 = new HashMap<String, Object>();
m3.put("value", "快来看看吧");
map.put("miniprogram_state",miniprogram_state);
map.put("lang", "zh_CN");
String r=HttpClient.doPost(url,JSON.toJSONString(map));
后台推送
String tk=WeixinUtil.getAccessToken().getToken();
String url="https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+tk;
Map<String, Object> map = new HashMap<String, Object>();
map.put("template_id", template_id);
map.put("touser", openid);
Map<String, Object> m1,m2 ,m3;
m1 = new HashMap<String, Object>();
m1.put("value", "天气提醒,你哈哈哦");
m2 = new HashMap<String, Object>();
m2.put("value", "今天天气很棒哦");
m3 = new HashMap<String, Object>();
m3.put("value", "快来看看吧");
map.put("miniprogram_state",miniprogram_state);
map.put("lang", "zh_CN");
String r=HttpClient.doPost(url,JSON.toJSONString(map));