WeChat XML format compatible

The Weibo message push service is fully compatible with the "WeChat XML format", so that third parties who have developed based on the WeChat public platform can migrate more smoothly; The third party can http://open.weibo.com/wiki/Eps/push/set_format Interface to choose whether you need XML or JSON format;

catalog

receive messages

TextXML format of 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>
Return Value Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type text
Content text Private message content
MsgId No corresponding field The content of this field is empty

XML format of 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>
Return Value Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type image
PicUrl No corresponding field The content of this field is empty
MediaID data:tovfid Private message content
MsgId No corresponding field The field is empty

XML format of 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>
Return Value Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type voice
PicUrl No corresponding field The content of this field is empty
MediaID data:tovfid Private message content
Format No corresponding field The field is empty
MsgId No corresponding field The field is empty

XML format of position 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 [Location information]]></Label> <MsgId>1234567890123456</MsgId> </xml>
Return Value Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type position
Location_X data:latitude latitude
Location_Y data:longitude longitude
Scale No corresponding field The field is empty
Label No corresponding field The field is empty
MsgId No corresponding field The field is empty

Follow/unsubscribe, subscribe/unsubscribe message XML format

 <xml> <ToUserName><! [CDATA[toUser]]></ToUserName> <FromUserName><! [CDATA[FromUser]]></FromUserName> <CreateTime>123456789</CreateTime> <MsgType><! [CDATA[event]]></MsgType> <Event><! [CDATA[subscribe]]></Event> </xml>
Return Value Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type event
Event data:subtype Follow: follow event, unsubscribe event, subscribe event, unsubscribe event.

Scan XML format of QR code events with parameters

When users scan QR codes with scene values, they may push the following two events: If the user has not followed the official account of the QR code generator, it will enter the following list after scanning; If the user clicks Follow, Weibo will push the scan_follow event to the third party;

 <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>
Return Value Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type event
Event data:subtype scan_follow
EventKey data:key Event Key value, with action_name as the prefix, followed by the scene_id value of the QR code
Ticket data:ticket QR code ticket, which can be used to exchange QR code pictures

If the user has followed the official account of the QR code generator, it will enter the private message dialogue interface with the official account after scanning, and Weibo will push scan events to a third party;

 <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>
Return Value Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type event
Event data:subtype scan
EventKey data:key Event Key value, with action_name as the prefix, followed by the scene_id value of the QR code
Ticket data:ticket QR code ticket, which can be used to exchange QR code pictures


XML format of custom menu event push

 <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>
Return Value Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type event
Event data:subtype Click is a user-defined menu click event, and view is a user-defined menu jump link event.
EventKey data:key The click event is the key value of the clicked custom menu, and the view event is the url set for the button.


Send passive response

XML format of reply 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> </xml>
Parameter Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type text
Content data:text Private message content; Weibo requires that the text size of the private message to be replied must be less than 300 Chinese characters; If there are more than 300 Chinese characters, Weibo will automatically truncate the excess

XML format of reply image text message

 <ToUserName><! [CDATA[toUser]]></ToUserName> <FromUserName><! [CDATA[fromUser]]></FromUserName> <CreateTime>12345678</CreateTime> <MsgType><! [CDATA[news]]></MsgType> <ArticleCount>2</ArticleCount> <Articles> <item> <Title><! [CDATA[title1]]></Title>  <Description><! [CDATA[description1]]></Description> <PicUrl><! [CDATA[picurl]]></PicUrl> <Url><! [CDATA[url]]></Url> </item> <item> <Title><! [CDATA[title]]></Title> <Description><! [CDATA[description]]></Description> <PicUrl><! [CDATA[picurl]]></PicUrl> <Url><! [CDATA[url]]></Url> </item> </Articles>
Return Value Description
XML Parameters Corresponding parameters in JSON format Description
ToUserName receiver_id Recipient of the message
FromUserName sender_id Sender of message
CreateTime created_at Message creation time
MsgType type articles
ArticleCount No corresponding field The content of this field will be automatically ignored; In addition, Weibo supports up to 8 images and texts. If there are more than 8 images and texts, Weibo will automatically truncate the more than 8 images and texts;
Title articles:display_name The display name title of the image and text must be less than 60 Chinese characters.
Description articles:summary The text size of the graphic text description must be less than 300 Chinese characters. It supports spaces and line breaks. Three or more spaces and line breaks are reduced to two.
PicUrl articles:image Image links of images and texts only support PNG and JPG types.
Url articles:url URL address of the image and text, click to jump.
Document update time: 2014-06-03