Common Messages
Back

From WeChat Official Account Admin Platform
Jump to: navigation, search

When a WeChat user sends a message to an Official Account, the WeChat Official Account Admin System POSTs an XML data package to the URL provided by the developer.

If a response from the developer's backend system is not received within five seconds, the WeChat Official Account System will close the connection and initiate a new request up to three times.

To avoid duplicate retry messages, it is recommended to use msgid.

If the developer's backend system cannot guarantee a reply back to the WeChat Official Account System within 5 seconds, a reply with an empty string should be returned to the WeChat Official Account System instead. In this case, the WeChat Official Account System will not attempt to resend the message.

An example of pushing XML data package is as follows:

Contents

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>
Parameter Description
ToUserName Developer's WeChat ID
FromUserName Unique sender ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Text
Content Message content
MsgId A unique message ID (64 bit integer)


Image 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>
Parameter Description
ToUserName Developer's WeChat ID
FromUserName Unique sender ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Image
PicUrl Image URL
MediaId The media ID for an image message to call to download a multimedia file's API
MsgId A unique message ID (64 bit integer)


Audio Messages

<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>
Parameter Description
ToUserName Developer's WeChat ID
FromUserName Unique sender ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Voice
MediaId The media ID for an audio message to call to download a multimedia file's API
Format Audio format such as amr and speex
MsgId A unique message ID (64 bit integer)


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>
Parameter Description
ToUserName Developer's WeChat ID
FromUserName Unique sender ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Video
MediaId The media ID for a video message to call to download a multimedia file's API
ThumbMediaId The media ID for a video message thumb to call to download a multimedia file's API
MsgId A unique message ID (64 bit integer)


Location Data Messages

<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[Location]]></Label>
<MsgId>1234567890123456</MsgId>
</xml> 
Parameter Description
ToUserName Developer's WeChat ID
FromUserName Unique sender ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Location
Location_X Latitude
Location_Y Longitude
Scale Map zoom size
Label Location information
MsgId A unique message ID (64 bit integer)


Link Messages

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1351776360</CreateTime>
<MsgType><![CDATA[link]]></MsgType>
<Title><![CDATA[Official Account Admin Platform Website Link]]></Title>
<Description><![CDATA[Official Account Admin Platform Website Link]]></Description>
<Url><![CDATA[url]]></Url>
<MsgId>1234567890123456</MsgId>
</xml> 
Parameter Description
ToUserName Developer's WeChat ID
FromUserName Unique sender ID (an OpenID)
CreateTime Message creation time (Integer)
MsgType Link
Title Message title
Description Message description
Url Message URL
MsgId A unique message ID (64 bit integer)
Developer Guide
Custom-defined Menu
WeChat JS-SDK