


Senparc.Weixin.MP SDK WeChat public platform development tutorial (2): Become a developer
I think it is more important to be prepared to become a developer than to activate the "advanced" functions of the WeChat backend in a daze, so I will put this section first.
1. Communication process of public platform
As developers, we mainly need to face two objects: WeChat server and application (website) server.
When a WeChat user sends a message to your public platform, the message is actually sent to the WeChat server first, and the WeChat server initiates another request to the website server. The website server returns the result of this request, and then the The WeChat server sends it to the WeChat client.
The entire message communication process is as follows:
Among the above 5 steps, as developers, we mainly focus on step 3. This step mainly focuses on There are actually 3 tasks:
Receive XML information from 2
Execute internal logic of the server
Organize and return XML information for 4
I will explain the above three tasks in detail later and provide a set of simple and efficient processing methods.
2. XML communication format
When users send different types of messages using the WeChat client, the website server will receive data in different formats (text, voice, pictures, etc.), data format Currently there is only XML.
For learning, I think as long as you are proficient in the simplest text types, other formats are similar. And in the following instructions, you will find that Senparc.Weixin.MP.dll can help us completely ignore these cumbersome formats and definitions.
A simple text request XML (RequestMessage) content is as follows:
<xml> <ToUserName><![CDATA[gh_a96a4a619366]]></ToUserName> <FromUserName><![CDATA[olPjZjsXuQPJoV0HlruZkNzKc91E]]></FromUserName> <CreateTime>1357986928</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[TNT2]]></Content> <MsgId>5832509444155992350</MsgId> </xml>
The official description of the corresponding node is as follows:
Parameters | Description |
---|---|
ToUserName | DeveloperWeChat ID |
FromUserName | Sender account (an OpenID) |
CreateTime | Message creation time (integer) |
MsgType | text |
Content | Text message content |
MsgId | Message id, 64-bit integer type |
##A simple text return XML (ResponseMessage) content is as follows:
<xml> <ToUserName><![CDATA[olPjZjsXuQPJoV0HlruZkNzKc91E]]></ToUserName> <FromUserName><![CDATA[gh_a96a4a619366]]></FromUserName> <CreateTime>12345678</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[content]]></Content> <FuncFlag>0</FuncFlag> </xml>
Description | |
---|---|
Receiver account (received OpenID) | |
Developer WeChat ID | |
Message creation time | |
text | |
Reply message content , the length does not exceed 2048 bytes | |
When bit 0x0001 is flagged, the star marks the message just received. |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
