Public platform development (III): Public Platform
1. Public platform message interaction process
As developers, we have two main targets: servers and application (website) servers.
When a user sends a message to your public platform, the message is actually sent to the server first. The server initiates another request to the website server, and the website server returns the result of this request, then the server sends it to the client.
The entire message communication process is as follows:
In the above five steps, as developers, we focus mainly on step 3, which actually requires three tasks:
I will describe the above three tasks in detail and provide a complete set of simple and efficient processing methods.
XML format of forwarded messages
<? Xml version = "1.0" encoding = "UTF-8"?> <Xml> <ToUserName> <! [CDATA [gh_a96a4a619366]> </ToUserName> <FromUserName> <! [CDATA [olPjZjsXuQPJoV0HlruZkNzKc91E]> </FromUserName> <CreateTime> 1357986928 </CreateTime> <MsgType> <! [CDATA [text]> </MsgType> <Content> <! </Content> <MsgId> 5832509444155992350 </MsgId> </xml>
The official description of the corresponding node is as follows:
Parameters |
Description |
ToUserName |
Developer ID |
FromUserName |
Sender account (one OpenID) |
CreateTime |
Message creation time (integer) |
MsgType |
Text |
Content |
Text message content |
MsgId |
Message id, 64-bit integer |
XML format of returned messages
<? Xml version = "1.0" encoding = "UTF-8"?> <Xml> <ToUserName> <! [CDATA [olPjZjsXuQPJoV0HlruZkNzKc91E]> </ToUserName> <FromUserName> <! [CDATA [gh_a96a4a619366]> </FromUserName> <CreateTime> 63497820384 </CreateTime> <MsgType> text </MsgType> <Content> <! [CDATA [text message you just sent: Chinese // You can also send [location] [Image] [Voice] information to view replies in different formats. // SDK official address: http://weixin.senparc.com]> </Content> </xml>
The official description of the corresponding node is as follows:
Parameters |
Description |
ToUserName |
Recipient account (received OpenID) |
FromUserName |
Developer ID |
CreateTime |
Message Creation Time |
MsgType |
Text |
Content |
The content of the reply message. The length cannot exceed 2048 bytes. |
FuncFlag |
The message received by the star when 0x0001 is marked. |
Some issues that need attention and are easily overlooked:
WeiXinMessageSDK source code download case source code