Joke Collection Website - Public benefit messages - How does WeChat public platform apply for message interface?
How does WeChat public platform apply for message interface?
The message interface of WeChat public platform provides a new message processing method for developers.
Second, the application message interface
Click Apply, truthfully fill in the name, mobile phone number and email address of the person in charge, and fill in the website address and token of the website. The token can be filled by the developer at will to generate the signature.
Three. Website visit
After the public platform user submits the information, we will request the filled Url in the form of GET request, which has four parameters:
* Signature-WeChat encrypted signature
* Timestamp-Timestamp
* Current random number
* echostr- random string
Developers check the legality of URL access by checking the signature. If the GET request returns the echostr parameter content as it is, the access will take effect, otherwise the access will fail. Verifying the signature will encrypt the process by combining token parameters, timestamp parameters and nonce parameters filled by the developer:
* Token, timestamp and nonce are sorted in dictionary order.
* Splicing three parameter strings into one string for SHA 1 encryption.
* The encrypted string obtained by the developer can be compared with the signature, indicating that the request originated from WeChat.
Fourth, message push.
When an ordinary WeChat user sends a message to a public account, the public platform will post the message to the filled Url (SMS and geographic location messages are now supported). Its structure is as follows:
Xml format of text message
& ltToUserName & gt& lt! [CDATA[toUser]]& gt; & lt/touser name & gt;
& ltfrom user name & gt& lt! [CDATA[from user]]& gt; & lt/from username & gt;
& ltCreateTime & gt 134883 1860 & lt; /create time & gt;
& ltMsgType & gt& lt! [CDATA[text]]& gt; & lt/msg type & gt;
& lt content & gt& lt! [CDATA[ This is a test] ]]& gt;; & lt/Content & gt;
& lt/XML & gt;
The micro-signal of the receiver of ToUserName message is generally the micro-signal of the public platform account.
FromUserName message sender micro signal
Message creation time
MsgType text messages are text.
Content message content geographic location message xml format
& ltToUserName & gt& lt! [CDATA[toUser]]& gt; & lt/touser name & gt;
& ltfrom user name & gt& lt! [CDATA[from user]]& gt; & lt/from username & gt;
& ltCreateTime & gt 135 1776360 & lt; /create time & gt;
& ltMsgType & gt& lt! [CDATA[location]]& gt; & lt/msg type & gt;
& ltLocation _ X & gt23. 13452 1 & lt; /Location _ X & gt;
& ltLocation _ Y & gt 1 13.358803 & lt; /Location _ Y & gt;
& ltScale & gt20 & lt/Scale & gt;
& lt label & gt& lt! [CDATA[ Location information] ]]& gt;; & lt/Label & gt;
& lt/XML & gt;
The micro-signal of the receiver of ToUserName message is generally the micro-signal of the public platform account.
FromUserName message sender micro signal
Message creation time
Message type with geographical location.
Location x geographic latitude
Location y geographical location longitude
Zoom map zoom size
Labeling geographical location information
Picture message structure
& ltToUserName & gt& lt! [CDATA[toUser]]& gt; & lt/touser name & gt;
& ltfrom user name & gt& lt! [CDATA[from user]]& gt; & lt/from username & gt;
& ltCreateTime & gt 134883 1860 & lt; /create time & gt;
& ltMsgType & gt& lt! [CDATA[image]]& gt; & lt/msg type & gt;
& ltPicUrl & gt& lt! [CDATA[ This is a URL]& gt;; & lt/pic URL & gt;
& lt/XML & gt;
The micro-signal of the receiver of ToUserName message is generally the micro-signal of the public platform account.
FromUserName message sender micro signal
Message creation time
Message type image
PicUrl image link, developers can use HTTP GET to get.
Verb (short for verb) message reply
For each POST request, the developer returns a specific xml structure in the response package and performs corresponding operations on the message (reply text message, reply graphic message and asterisk operation are now supported). The xml structure is as follows:
Reply text message format
& ltToUserName & gt& lt! [CDATA[toUser]]& gt; & lt/touser name & gt;
& ltfrom user name & gt& lt! [CDATA[from user]]& gt; & lt/from username & gt;
& ltCreateTime & gt 12345678 & lt; /create time & gt;
& ltMsgType & gt& lt! [CDATA[text]]& gt; & lt/msg type & gt;
& lt content & gt& lt! [CDATA[content]]& gt; & lt/Content & gt;
& ltFuncFlag & gt0 & lt/func flag & gt;
& lt/XML & gt;
Sender User Name Message Sender
User name message receiver
Message creation time
MsgType message type, text message must be filled in with text.
Content message content, the size is limited to 2048 bytes, the field is empty, and the format is illegal. Please reply to the graphic message.
& ltToUserName & gt& lt! [CDATA[toUser]]& gt; & lt/touser name & gt;
& ltfrom user name & gt& lt! [CDATA[from user]]& gt; & lt/from username & gt;
& ltCreateTime & gt 12345678 & lt; /create time & gt;
& ltMsgType & gt& lt! [CDATA[ News] ]]& gt;; & lt/msg type & gt;
& lt content & gt& lt! [CDATA[]]& gt; & lt/Content & gt;
& ltArticleCount & gt2 & lt/article count & gt;
& lt articles & gt
& ltitem & gt
& ltTitle & gt& lt! [CDATA[title 1]]& gt; & lt/Title & gt;
& lt description & gt& lt! [CDATA[description 1]]& gt; & lt/Description & gt;
& ltPicUrl & gt& lt! [CDATA[picurl]]& gt; & lt/pic URL & gt;
& ltUrl & gt& lt! [CDATA WeChat website /cgi-bin/...star= 1]
This email was found in the classification of interstellar mail.
Sixth, the sample code PHP: download
Seven, enter the WeChat forum for discussion.
- Related articles
- Why can't I get the verification code by texting?
- How to turn off vivo mobile phone
- Words of thanks to the boss on Women’s Day
- How to operate ICBC e-payment?
- April Fool's Day funny prank pictures
- What subjects does the enterprise online banking SMS reminder fee include?
- Payment time of medical insurance for flexible employees in Danyang 2023
- What should I do if I can't receive the intercepted SMS?
- Does Iphone4 use electricity even for texting?
- Glory x20se voice call didn't ring.