receive normal messages


Receive ordinary messages

##When ordinary WeChat users send messages to public accounts, The WeChat server packages the XML data of the POST message to the URL filled in by the developer.

Please note:

1. Regarding retry message duplication, it is recommended to use msgid to deduplicate messages.

2. If the WeChat server does not receive a response within five seconds, it will disconnect and re-initiate the request, retrying three times in total. If the server cannot guarantee to process and reply within five seconds,

can directly reply with an empty string. The WeChat server will not do anything with this and will not initiate a retry. For details, please see "Send a Message - Passive Reply to a Message".

3. If the developer needs to respond immediately to the user's message within 5 seconds, that is, when using the "Send Message-Passive Reply Message" interface to passively reply to the user's message, he can do so in

Message encryption is set in the Developer Center of the official website of the public platform. After encryption is turned on, messages sent by users and messages replied by developers will be encrypted (but messages sent by developers through API calls such as the customer service

interface will not be affected). For detailed instructions on message encryption and decryption, please see "Sending Messages - Passive Reply Message Encryption and Decryption Instructions".

The push XML data packet structure of each message type is as follows:

Text message

##<xml>

<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
< ;CreateTime>1348831860</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[this is a test]] ></Content>
<MsgId>1234567890123456</MsgId>
</xml>

QQ截图20170207160054.png

Use web debugging tools to debug this interface

Picture message

<xml>
 <ToUserName><![CDATA[toUser]]></ToUserName>
 <FromUserName><![CDATA[fromUser]]></FromUserName>
 <CreateTime>1348831860</CreateTime>
 <MsgType><![CDATA[image]]></MsgType>
 <PicUrl><![CDATA[this is a url]]></PicUrl>
 <MediaId><![CDATA[media_id]]></MediaId>
 <MsgId>1234567890123456</MsgId>
 </xml>

QQ截图20170207160115.png

Use the web debugging tool to debug the interface

Voice message

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1357290913</CreateTime>
<MsgType><![CDATA[voice]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<Format><![CDATA[Format]]></Format>
<MsgId>1234567890123456</MsgId>
</xml>

QQ截图20170207160130.png

Use web debugging tools to debug this interface


Please note that after enabling speech recognition, every time a user sends a voice message to an official account, WeChat will add a Recongnition field to the pushed voice message XML packet (Note: Due to client caching, developers may enable or disable speech recognition. The function takes effect immediately for new followers and takes 24 hours for already followed users. Developers can re-follow this account for testing). The voice XML data packet after enabling speech recognition is as follows:

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1357290913</CreateTime>
<MsgType><![CDATA[voice]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<Format><![CDATA[Format]]></Format>
<Recognition><![CDATA[腾讯微信团队]]></Recognition>
<MsgId>1234567890123456</MsgId>
</xml>

Parameter description:

QQ截图20170207160144.png

Video message

##
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1357290913</CreateTime>
<MsgType><![CDATA[video]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<ThumbMediaId><![CDATA[thumb_media_id]]></ThumbMediaId>
<MsgId>1234567890123456</MsgId>
</xml>

QQ截图20170207160157.png

Use web debugging tools to debug this interface

Small video message

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1357290913</CreateTime>
<MsgType><![CDATA[shortvideo]]></MsgType>
<MediaId><![CDATA[media_id]]></MediaId>
<ThumbMediaId><![CDATA[thumb_media_id]]></ThumbMediaId>
<MsgId>1234567890123456</MsgId>
</xml>

QQ截图20170207160213.png

Use web debugging tools to debug this interface

Geolocation message

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1351776360</CreateTime>
<MsgType><![CDATA[location]]></MsgType>
<Location_X>23.134521</Location_X>
<Location_Y>113.358803</Location_Y>
<Scale>20</Scale>
<Label><![CDATA[位置信息]]></Label>
<MsgId>1234567890123456</MsgId>
</xml>

QQ截图20170207160227.png

Use web debugging tools to debug this interface

Link message

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1351776360</CreateTime>
<MsgType><![CDATA[link]]></MsgType>
<Title><![CDATA[公众平台官网链接]]></Title>
<Description><![CDATA[公众平台官网链接]]></Description>
<Url><![CDATA[url]]></Url>
<MsgId>1234567890123456</MsgId>
</xml>

QQ截图20170207160240.png

Use web debugging tools to debug this interface

1474853419807464.jpg