开发微信订阅消息推送
1,微信基础配置WxContanst.java:
1 package com.pgo.modules.inv.subscribe; 2 3 public class WxContanst { 4 5 private static String APPID = "微信公众平台查看APPID"; 6 7 private static String SECRET = "微信公众平台查看SECRET"; 8 9 //用于测试,后期可维护到数据库中,公众平台配置 10 public static String TEMPLATE_ID_ = "z8eVgH_fEY-s-IE57-jbB0uYySJMb2hysm1yR2zPH0w"; 11 12 13 // 微信小程序获取tokenURL 14 public static String TOKEN_URL_ = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" 15 + WxContanst.APPID + "&secret=" + WxContanst.SECRET; 16 17 // 获取小程序openid的url 18 public static String URL(String js_code) { 19 return "https://api.weixin.qq.com/sns/jscode2session?appid=" + WxContanst.APPID + "&secret=" + WxContanst.SECRET 20 + "&js_code=" + js_code + "&grant_type=authorization_code"; 21 } 22 23 /** 24 * 获取消息订阅的Url 25 * @param accessToken接口认证 26 * @return 消息订阅的Url 27 */ 28 public static String subscribeUrl(String accessToken){ 29 return "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken ; 30 } 31 32 }