Tools Tags
Backend Development
PHP
WeChat public platform developer documentation
Passively reply to user messages
directory
Tools Tags
Passively reply to user messages
Passive reply to user messages
When a user sends a message to the official account (or when events are pushed due to certain specific user operations), a POST request will be generated. Developers can respond to the message by returning a specific XML structure in the response package (Get) (reply text, pictures, graphics, voice, video, and music are now supported). Strictly speaking, sending a passive response message is not actually an interface, but a reply to a message sent by the WeChat server.
After the WeChat server sends the user's message to the official account's developer server address (configured in the developer center), if the WeChat server does not receive a response within five seconds, it will disconnect and re-initiate the request. , retry three times in total. If during debugging, you find that the user cannot receive the response message, you can check whether the message processing times out. Regarding retry message deduplication, it is recommended to use msgid to deduplicate messages with msgid. It is recommended to use FromUserName CreateTime to deduplicate event type messages.
If developers want to enhance security, they can turn on message encryption in the developer center. In this way, messages sent by users to official accounts and passive replies to user messages from official accounts will continue to be encrypted (but). For details, see Passive Reply Message encryption and decryption instructions.
If the server cannot guarantee to process and reply within five seconds, the following reply must be made, so that the WeChat server will not do anything with it and will not initiate a retry (in this case, you can Use the customer service message interface for asynchronous reply), otherwise, a serious error message will appear. See the instructions below for details:
1. Directly reply to success (recommended method) 2. Directly reply to an empty string (referring to an empty string with a byte length of 0, rather than The content of the content field in the XML structure is empty) |
Once the following situations are encountered, WeChat will issue the message to the user in the public account session The system prompts "This official account is temporarily unable to provide services, please try again later":
| 1. The developer did not reply with any content within 5 seconds 2. The developer responded with abnormal data, such as JSON data, etc. |
In addition, please note that when replying to multimedia messages such as pictures, you need to upload temporary materials to the WeChat server through the material management interface in advance. You can use temporary materials in material management or permanent materials.
Reply to text message
| ##<xml><ToUserName><! [CDATA[toUser]]></ToUserName><FromUserName><![CDATA[fromUser]]></FromUserName><CreateTime>12345678< ;/CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[Hello]] ></Content></xml> |
| Parameter | Is it required | Description |
|---|---|---|
| ToUserName | is the | receiver account (received OpenID) |
| FromUserName | is the | developer WeChat ID |
| CreateTime | is the | message creation time (integer) |
| MsgType | is | text |
| Content | is the message content of | (line break: line breaks can be made in content , WeChat client supports line wrap display) |
Reply to picture message
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>12345678</CreateTime> <MsgType><![CDATA[image]]></MsgType> <Image> <MediaId><![CDATA[media_id]]></MediaId> </Image> </xml> |
| Parameter | Is it required | Description |
|---|---|---|
| ToUserName | is the | receiver account (received OpenID) |
| FromUserName | is the | developer WeChat ID |
| CreateTime | is the | message creation time (integer) |
| MsgType | is | image |
| MediaId | is | Upload multimedia files through the interface in material management , the obtained id. |
Reply to voice message
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>12345678</CreateTime> <MsgType><![CDATA[voice]]></MsgType> <Voice> <MediaId><![CDATA[media_id]]></MediaId> </Voice> </xml> |
| Parameter | Is it required | Description |
|---|---|---|
| ToUserName | is the | receiver account (received OpenID) |
| FromUserName | is the | developer Wechat ID |
| CreateTime | is the | message creation timestamp (integer) |
| MsgType | is | voice, voice |
| MediaId | is | Upload multimedia files through the interface in material management , the obtained id |
Reply to video message
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>12345678</CreateTime> <MsgType><![CDATA[video]]></MsgType> <Video> <MediaId><![CDATA[media_id]]></MediaId> <Title><![CDATA[title]]></Title> <Description><![CDATA[description]]></Description> </Video> </xml> |
| Parameter | Is it required | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ToUserName | Yes | Receiver account (received OpenID) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FromUserName | is | Developer WeChat ID | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CreateTime | is | Message creation time (integer) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MsgType | is | video | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is the id | ## obtained by uploading multimedia files through the interface in material management. | #Title | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Title of video message | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Video message description of | Reply to Music Message
##Reply to graphic message
![]()
Hot AI Tools
Undress AI Tool
Undress images for free
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undresser.AI Undress
AI-powered app for creating realistic nude photos
ArtGPT
AI image generator for creative art from text prompts.
Stock Market GPT
AI powered investment research for smarter decisions
Hot Article
How to use AI Speech Enhancement in Premiere? (Audio Cleanup Guide)
1 months ago By 下次还敢
How to correctly migrate jQuery's drag and drop events to native JavaScript
4 weeks ago By DDD
What is 'EVM'? The significance of the Ethereum Virtual Machine
1 months ago By DDD
The Notepad upgrade, cheaper YouTube TV, and Nova Launcher's new owner: News roundup
3 weeks ago By DDD
How to dynamically set arbitrary depth value of nested array in PHP
1 months ago By DDD
Hot Topics
# Douyin level price list 1-75
20516
7
# wifi shows no ip assigned
13629
4
Popular tool
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3) |













![Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]](https://img.php.cn/upload/course/000/000/035/5d27fb58823dc974.jpg)









