# 本节知识点
- 1,注册微信公号测试账号
- 2,获取测试账号的用户openid
- 3,接入微信推送sdk
- 4,实现微信推送
# 课程中用到的网址和文件
- 1,微信官方注册测试账号:[https://mp.weixin..com/debug/cgi-bin/sandbox?t=sandbox/login](https://links.jianshu.com/go?to=https%3A%2F%2Fmp.weixin..com%2Fdebug%2Fcgi-bin%2Fsandbox%3Ft%3Dsandbox%2Flogin)
# 配套笔记
[5行代码实现微信模版消息推送](https://www.jianshu.com/p/bc5f)
# 视频地址
在线视频:[https://edu.csdn.net/course/detail/23750](https://edu.csdn.net/course/detail/23750)
网盘视频:加老师微信索要视频资源。
最好跟着老师的教程敲代码,如果实在敲不出来,再加老师微信索要源码。
# 核心代码
- 1 三方类库
<!--微信模版消息推送三方sdk--><dependency><groupId>com.github.binarywang</groupId><artifactId>weixin-java-mp</artifactId><version>3.3.0</version></dependency>
- 2 推送的核心类
public String push() {//1,配置WxMpInMemoryConfigStorage wxStorage = new WxMpInMemoryConfigStorage();wxStorage.setAppId("wx77bba000");//appidwxStorage.setSecret("29bd5ade62806e");//appsecretWxMpService wxMpService = new WxMpServiceImpl();wxMpService.setWxMpConfigStorage(wxStorage);//2,推送消息WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder().toUser("o5kho6DgC7SDry8zCmXuvHJGvrgI")//要推送的用户openid.templateId("Tpln-Eue2obJ0B-8JNkgkiRJaDMPgVeIgGxna982xrg")//模版id.url(002java基础视频"https://30paotui.com/")//点击模版消息要访问的网址.build();//3,发起推送try {String msg = wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);System.out.println("推送成功:" + msg);return "推送成功:" + msg;} catch (Exception e) {System.out.println("推送失败:" + e.getMessage());e.printStackTrace();}return "推送失败";}
# 老师微信
(备注小程序)
# 学习群

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/6374.html