当前位置:网站首页>[wechat official account H5] generates a QR code with parameters to enter the official account attention page to listen to user-defined menu bar for official account events (server)
[wechat official account H5] generates a QR code with parameters to enter the official account attention page to listen to user-defined menu bar for official account events (server)
2022-06-26 00:03:00 【Wukong_ Senior brother_】
official account Generate QR code with parameters Scan the code with parameters to enter the following official account page
Official documents :https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html
Temporary QR code request description
http Request mode : POST URL: https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN POST data format :json POST Data example :{"expire_seconds": 604800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": 123}}} Or you can use the following POST Two dimensional code parameters in the form of data creation string :{"expire_seconds": 604800, "action_name": "QR_STR_SCENE", "action_info": {"scene": {"scene_str": "test"}}}
Permanent QR code request description
http Request mode : POST URL: https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN POST data format :json POST Data example :{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": 123}}} Or you can use the following POST Two dimensional code parameters in the form of data creation string : {"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "test"}}}
Parameter description
Parameters explain expire_seconds Effective time of the QR code , In seconds . No more than 2592000( namely 30 God ), If this field is not filled in , The default validity period is 30 second . action_name QR code type ,QR_SCENE Is a temporary integer parameter value ,QR_STR_SCENE Is a temporary string parameter value ,QR_LIMIT_SCENE Is a permanent integer parameter value ,QR_LIMIT_STR_SCENE Is a permanent string parameter value action_info QR code details scene_id Scene value ID, Temporary QR code 32 Bit non 0 integer , The maximum value for permanent QR code is 100000( Currently, only parameters are supported 1--100000) scene_str Scene value ID( In string form ID), String type , The length is limited to 1 To 64
The code scanning belt parameters are processed after entering the official account
Official documents :https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html
Scan QR code events with parameters
When users scan QR code with scene value , Two types of events may be pushed :
- If the user has not paid attention to the official account , Users can pay attention to the official account. , After following, wechat will push the following events with scenario value to the developer .
- If the user has paid attention to the official account number , Wechat will push the event with scenario value scan to the developer .
1. When the user is not paying attention , Push events after attention
push XML Packet example :
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[FromUser]]></FromUserName> <CreateTime>123456789</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[subscribe]]></Event> <EventKey><![CDATA[qrscene_123123]]></EventKey> <Ticket><![CDATA[TICKET]]></Ticket> </xml>Parameter description :
Parameters describe ToUserName Developer WeChat ID FromUserName Sender account ( One OpenID) CreateTime Message creation time ( integer ) MsgType Message type ,event Event Event type ,subscribe EventKey event KEY value ,qrscene_ The prefix , The following is the parameter value of the QR code Ticket Two dimensional coded ticket, Can be exchanged for QR code pictures 2. Event push when the user has followed
push XML Packet example :
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[FromUser]]></FromUserName> <CreateTime>123456789</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[SCAN]]></Event> <EventKey><![CDATA[SCENE_VALUE]]></EventKey> <Ticket><![CDATA[TICKET]]></Ticket> </xml>Parameter description :
Parameters describe ToUserName Developer WeChat ID FromUserName Sender account ( One OpenID) CreateTime Message creation time ( integer ) MsgType Message type ,event Event Event type ,SCAN EventKey event KEY value , It's a 32 Bit unsigned integer , That is, the QR code when the QR code is created scene_id Ticket Two dimensional coded ticket, Can be exchanged for QR code pictures
official account Users click or cancel following Event monitoring
Official documents :https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html
Focus on / Unfollow events
Users are concerned about and cancelling the official account. , Wechat will push this event to the developer to fill in URL. It is convenient for developers to send welcome messages to users or unbind accounts . To protect user data privacy , The developer needs to delete all information of the user when receiving the event of user's cancellation of attention .
If the wechat server does not receive a response within five seconds, it will be disconnected , And reissue the request , Three retries in total .
Message retrying , Recommended FromUserName + CreateTime Weight removal .
If the server cannot guarantee to process and reply within five seconds , Can reply empty string directly , Wechat server will not handle this , And will not initiate a retry .
push XML Packet example :
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[FromUser]]></FromUserName> <CreateTime>123456789</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[subscribe]]></Event> </xml>Parameter description :
Parameters describe ToUserName Developer WeChat ID FromUserName Sender account ( One OpenID) CreateTime Message creation time ( integer ) MsgType Message type ,event Event Event type ,subscribe( subscribe )、unsubscribe( Unsubscribe )
official account Custom menu bar
Official documents :https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html
Custom menu events
After the user clicks the custom menu , Wechat will push click events to developers , Please note that , Click menu to pop up submenu , No escalation .
Event push when clicking menu to pull message
push XML Packet example :
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[FromUser]]></FromUserName> <CreateTime>123456789</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[CLICK]]></Event> <EventKey><![CDATA[EVENTKEY]]></EventKey> </xml>Parameter description :
Parameters describe ToUserName Developer WeChat ID FromUserName Sender account ( One OpenID) CreateTime Message creation time ( integer ) MsgType Message type ,event Event Event type ,CLICK EventKey event KEY value , Interface with custom menu KEY Value correspondence Event push when clicking menu jump link
push XML Packet example :
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[FromUser]]></FromUserName> <CreateTime>123456789</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[VIEW]]></Event> <EventKey><![CDATA[www.qq.com]]></EventKey> </xml>Parameter description :
Parameters describe ToUserName Developer WeChat ID FromUserName Sender account ( One OpenID) CreateTime Message creation time ( integer ) MsgType Message type ,event Event Event type ,VIEW EventKey event KEY value , Jump set URL
After users' attention The official account is accessible to the public. OpenID adopt OpenID To get basic user information Please see the document for details
Get basic user information (UnionID Mechanism )
Get basic user information ( Include UnionID Mechanism )
Developers can use OpenID To get basic user information . Please use https agreement .
Interface call request description http Request mode : GET
https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
Parameter description 
Return instructions
Under normal circumstances , Wechat will return the following JSON Packet to official account :

边栏推荐
- Some common operation methods of array
- 使用npm创建并发布包时遇到的常见问题
- ASA如何配置端口映射及PAT
- 格式化编号,不够位数的补0,例如1:0001,25:0025
- Studio5k v28安装及破解_过路老熊_新浪博客
- One article explains R & D efficiency! Your concerns are
- 别再吃各种维生素C片了,这6种维生素C含量最高的水果
- WINCC与STEP7的仿真连接_过路老熊_新浪博客
- Doris 运维中遇到的问题
- Stop eating vitamin C tablets. These six fruits have the highest vitamin C content
猜你喜欢
![mysql5.7版本在配置文件my.ini[mysqld]加上skip-grant-tables后无法启动](/img/b2/2b87b3cea1422e2a860f5e0e7dcc40.png)
mysql5.7版本在配置文件my.ini[mysqld]加上skip-grant-tables后无法启动

关于运行scrapy项目时提示 ModuleNotFoundError: No module named 'pymongo‘的解决方案

How to configure SQL Server 2008 Manager_ Old bear passing by_ Sina blog

如何配置SQL Server 2008管理器_过路老熊_新浪博客

7.常用指令(下)v-on,v-bind,v-model的常见操作

用frp搭建云电脑

SSL/TLS、对称加密和非对称加密和TLSv1.3

Efficacy of kiwi fruit enzyme_ Old bear passing by_ Sina blog

Final and static

Some common operation methods of array
随机推荐
SSM integrated learning notes (mainly ideas)
【微信公众号H5】 生成带参数进入公众号关注页的二维码 监听用户关注公众号事件 自定义菜单栏 (服务端)
dhcp复习
Common knowledge points in JS
postman如何测试需要登录的接口
Realize the conversion between analog quantity value and engineering quantity value in STEP7_ Old bear passing by_ Sina blog
剑指 Offer 48. 最长不含重复字符的子字符串
Establishment of multiple background blocks in botu software_ Old bear passing by_ Sina blog
DPVS-FullNAT模式管理篇
6. common instructions (upper) v-cloak, v-once, v-pre
PHP interprocess pass file descriptor
ASA如何配置端口映射及PAT
对伪类的理解
在win10下使用visual studio2015链接mysql数据库
About the swoole coroutine container
Transformation of communication protocol between Siemens S7-200PLC and Danfoss inverter_ Old bear passing by_ Sina blog
社交网络可视化第三方库igraph的安装
文獻調研(三):數據驅動的建築能耗預測模型綜述
Use Baidu map API to set an overlay (infowindow) in the map to customize the window content
iomanip头文件在实战中的作用