package com.zoniot.ccrc.commom.utils; import java.io.IOException; /** * 微信公众号消息推送 */ public class SendWechatPush { /** * 统一消息发送异常通知(微信公众号和小程序) */ public static String sendAbnormalNotice(String accessToken,String oa_appid, String openId, String url,String weapp_appid, String pagepath, String first, String keyword1, String keyword2, String keyword3, String remark) { if (accessToken != null && !"".equals(accessToken)) { String sendUrl = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=" + accessToken; String json = "{\n" + " \"touser\": \""+openId+"\",\n" + " \"mp_template_msg\": {\n" + " \"appid\": \""+oa_appid +"\",\n" + " \"template_id\": \"r8mtd2mgMt8w-sNgHsJ4deoD2bfq-0RyK9lCY3WEoxI\",\n" + " \"url\": \""+url+"\",\n" + " \"miniprogram\": {\n" + " \"appid\": \""+weapp_appid+"\",\n" + " \"path\": \""+pagepath+"\"\n" + " },\n" + " \"data\": {\n" + " \"first\": {\n" + " \"value\": \""+first+"\",\n" + " \"color\": \"#173177\"\n" + " },\n" + " \"keyword1\": {\n" + " \"value\": \""+keyword1+"\",\n" + " \"color\": \"#173177\"\n" + " },\n" + " \"keyword2\": {\n" + " \"value\": \""+keyword2+"\",\n" + " \"color\": \"#173177\"\n" + " },\n" + " \"keyword3\": {\n" + " \"value\": \""+keyword3+"\",\n" + " \"color\": \"#173177\"\n" + " },\n" + " \"remark\": {\n" + " \"value\": \""+remark+"\",\n" + " \"color\": \"#173177\"\n" + " }\n" + " }\n" + " }\n" + "}"; try { return HttpRequest.doPost(sendUrl, json); } catch (IOException e) { return null; } } else { return "accessToken不存在"; } } }