当前位置:网站首页>Super detailed steps for pushing wechat official account H5 messages
Super detailed steps for pushing wechat official account H5 messages
2022-07-06 10:10:00 【Eric-x】
Preface
Some time ago, I made a project for H5 Message push function , It is hereby recorded that , Interested or needed friends can check , Because the code is not difficult , I think what is difficult for beginners is some concepts and specific implementation process , So I will use the test interface provided by wechat to go through the process first , The corresponding implementation code will be posted later , In this way, both you and I will have a clearer understanding of the implementation of the overall process , If there is anything wrong, please point out ( Hug and thank you )
The renderings are as follows :
Article title
List of articles
1、 Concept
I think we must understand the concept of some keywords in the document before docking with the third-party interface , The meaning of , In this way, I won't be confused by the documents ( In fact, I was confused when I read the third-party interface documents , Especially wechat , Make complaints about it here. , Alibaba's documents are better , Easy to understand )
I won't say much here , Briefly introduce several concepts used in our function : Wechat service number official document link
We try to focus here , Nothing else
1、Access token
access_token The official account is the only global interface invoke credential. , Official account calls for interfaces. access_token.
This sentence is officially said , In fact, we can understand it as :token It's the ID card of the service number , Have uniqueness , And this credential requires our service number APPID and secret These two values are obtained . In fact, there is another value ,grant_type, I won't say much about this value , There are many introductions on the Internet , obtain access_token Fill in client_credential that will do .
2、APPID
Third party user unique credentials , As long as we open the service number, we will have this thing
3、secret
Third party user unique credential key , namely appsecret
The official introduction is as follows :
APPID and secret When we register the service number, we can get , So with these two values , We can use these two values to request the official link to get our token
2、 obtain Token
For learners , It's still hard to apply for a service number , therefore , Wechat officials are very considerate to give us the interface for testing : Wechat development test interface 、 Go to this link , Log in with wechat scanning code , You can get :APPID and appsecret 了
Then we can provide through wechat Test interface , Take us APPID and APPsecret Fill in , We can get our token 了 ,token The default validity period is two hours , as follows
3、 Add message template
We have taken the first step above , Then this is not enough , If you need to pay attention to our service number ( official account ) Send messages to users of , We need a message template , The template is added here
Here to take care of beginners , I put my test template content here for you to copy directly
{
{
first.DATA}}
Inform the content :{
{
keyword1.DATA}}
{
{
remark.DATA}}
4、 Get the user's openId
About openId, Here's a special note ,openId It is aimed at users , With our service number APPID It doesn't matter ( I got confused about this at the beginning ), Our wechat only needs to pay attention to a official account , Then this official account will be assigned to our wechat openId, It's the only one , Here's the thing to note , Even if we cancel our attention , The second time I paid attention to that openid Or before , It won't change .
Because we are notifying the designated users , Then we need to get the user's openId
5、 test
good , Now we have everything , You can test directly , still , Open up our Wechat debugging tools
1、 Get our... First token, Input APPID And secret key , Click directly to get , Then it will automatically generate Token, We directly copy and retain
2、 Hang to send details to users , Then take token And message content
The above is the general process and idea , Know the specific implementation process , Then the code is not difficult to write , Write the corresponding code next time
边栏推荐
- C杂讲 双向循环链表
- 通过bat脚本配置系统环境变量
- Jar runs with error no main manifest attribute
- Regular expressions are actually very simple
- MySQL实战优化高手10 生产经验:如何为数据库的监控系统部署可视化报表系统?
- 颜值爆表,推荐两款JSON可视化工具,配合Swagger使用真香
- Why can't TN-C use 2p circuit breaker?
- max-flow min-cut
- C miscellaneous shallow copy and deep copy
- Competition vscode Configuration Guide
猜你喜欢
A necessary soft skill for Software Test Engineers: structured thinking
Redis集群方案应该怎么做?都有哪些方案?
Learning SCM is of great help to society
What should the redis cluster solution do? What are the plans?
四川云教和双师模式
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
C miscellaneous dynamic linked list operation
MySQL Real Time Optimization Master 04 discute de ce qu'est binlog en mettant à jour le processus d'exécution des déclarations dans le moteur de stockage InnoDB.
MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位
Control the operation of the test module through the panel in canoe (Advanced)
随机推荐
MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位
[one click] it only takes 30s to build a blog with one click - QT graphical tool
Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
Southwest University: Hu hang - Analysis on learning behavior and learning effect
嵌入式開發中的防禦性C語言編程
Teach you how to write the first MCU program hand in hand
C miscellaneous shallow copy and deep copy
Canoe cannot automatically identify serial port number? Then encapsulate a DLL so that it must work
好博客好资料记录链接
Elk project monitoring platform deployment + deployment of detailed use (II)
CANoe的数据回放(Replay Block),还是要结合CAPL脚本才能说的明白
寶塔的安裝和flask項目部署
西南大学:胡航-关于学习行为和学习效果分析
在CANoe中通過Panel面板控制Test Module 運行(初級)
Zsh configuration file
MySQL combat optimization expert 06 production experience: how does the production environment database of Internet companies conduct performance testing?
Mexican SQL manual injection vulnerability test (mongodb database) problem solution
C杂讲 动态链表操作 再讲
Why is 51+ assembly in college SCM class? Why not come directly to STM32
MySQL combat optimization expert 04 uses the execution process of update statements in the InnoDB storage engine to talk about what binlog is?