Send a message---passively reply to a user message

Source: Internet
Author: User
Tags cdata openid

For each POST request, the developer returns a specific XML structure in the response package (Get) that responds to the message (now supports reply text, pictures, graphics, voice, video, music). Please note that when replying to a multimedia message such as a picture, you need to upload the multimedia file to the server and only support the authentication service number.

the server fails to receive a response within five seconds and the connection is disconnected, and the request is re-initiated, with a total of three retries , and if, in debugging, a message is found that the user is not receiving a response, you can check whether the message processing timed out.

For message MsgId of retry, it is recommended to use MsgId. Event type messages are recommended for use with Fromusername + createtime.

Send a passive response message is not an interface, but a reply to the server sent a message, if the server can not guarantee processing and reply within five seconds, you must reply to an empty string (refers to the reply to an empty strings, rather than an XML structure in the contents of the Content field is empty, Do not misunderstand), the server does not handle this and does not initiate a retry. . In this case, you can use the Customer Service messaging interface for asynchronous replies.

Please note that, in the event of the following, the user will be issued a system in the public session, "the public number is temporarily unable to provide services, please try again later":

1, the developer did not reply to any content within 5 seconds 2, the developer replied to the abnormal data, such as JSON data, etc.

The XML packet structure required for each message type is as follows.

Directory
  • 1 reply text message
  • 2 reply to Picture message
  • 3 Reply to a voice message
  • 4 reply to a video message
  • 5 reply to music messages
  • 6 reply text message
Reply text message
 <xml><tousername><! [cdata[touser]]></tousername><fromusername><! [cdata[fromuser]]></fromusername><createtime>12345678</createtime><msgtype><! [cdata[text]]></msgtype><content><! [cdata[Hello]]></content></xml> 
parameter must
tousername Yes recipient account (Received OpenID)
fromusername Yes developer #
createtime Yes message creation time (int)
msgtype Yes text
Content is a reply message content (newline: can wrap in content, the client supports line break 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 must description
tousername Yes Recipient account (Received OpenID)
fromusername Yes developer no
createtime Yes message creation time (integer)
msgtype yes im Age
mediaid is the ID obtained by uploading a multimedia file.

reply to a 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 must description
tousername Yes Recipient account (Received OpenID)
fromusername Yes developer no
createtime Yes message creation Timestamp (integer)
msgtype Yes Audio, Voice
mediaid yes upload multimedia file, get ID

reply to a 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>
Parameters whether you must Description
Tousername Is Recipient's account (OpenID received)
Fromusername Is Developer Number
Createtime Is Message creation time (integer type)
Msgtype Is Video
MediaID Is By uploading a multimedia file, get the ID
Title Whether Title of the video message
Description Whether Description of the video message
reply to music messages
 <xml><tousername><! [cdata[touser]]></tousername><fromusername><! [cdata[fromuser]]></fromusername><createtime>12345678</createtime><msgtype><! [cdata[music]]></msgtype><music><title><! [cdata[title]]></title><description><! [cdata[description]]></description><musicurl><! [cdata[music_url]]></musicurl>
must description
T Ousername is recipient account (OpenID received)
fromusername Yes development number
createtime Yes message creation time (integer)
msgtype Yes music
Title no music title
Description no music description
musicurl no music link
hqmusicurl no high-quality music links, WiFi environment first use the link to play music
thumbmediaid is the media ID of the thumbnail, and the ID obtained by uploading the multimedia file

Reply text message
 <xml><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></xml> 
Parameters whether you must Description
Tousername Is Recipient's account (OpenID received)
Fromusername Is Developer Number
Createtime Is Message creation time (integer type)
Msgtype Is News
Articlecount Is The number of text messages, limited to 10 items or less
Articles Is Multiple text message information, the default first item is a large image, note that if the number of text is more than 10, it will be unresponsive
Title Whether Text Message title
Description Whether Text message Description
Picurl Whether Image link, support JPG, PNG format, good effect for large image 360*200, small figure 200*200
Url Whether Click the text message jump link

Send a message---passively reply to a user message

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.