The message interface of the public platform provides developers with a new message processing method. The message interface of the public platform provides developers with the ability to exchange messages with users. For a public account that successfully accesses the Message Interface, when a user sends a message to the public account, the public platform server uses an http request to push messages to the Accessed URL.
Introduction
The message interface of the public platform provides developers with a new message processing method. The message interface of the public platform provides developers with the ability to exchange messages with users. For a public account that successfully accesses the Message Interface, when a user sends a message to the public account, the public platform server uses an http request to push messages to the Accessed URL, A third-party server can reply to a message through a response packet.
Message application interface
Click Apply and enter the url and token. you can enter the token as needed to generate a signature.
Website Access
After a public platform user submits information, the server sends a GET request to the URL filled in with four parameters:
Parameters |
Description |
Signature |
Encrypted signature |
Timestamp |
Timestamp |
Nonce |
Random number |
Echostr |
Random string |
The developer verifies the request by verifying signature (The following is a verification method ). If you confirm that the GET request is from the server, the echostr parameter is returned as is, and the access takes effect. Otherwise, the access fails.
Signature combines the token parameter entered by the developer with the timestamp parameter and nonce parameter in the request.
Encryption/verification process:
- Sort the tokens, timestamp, and nonce in lexicographic order.
- Splice the three parameter strings into one string for sha1 encryption
- The encrypted string obtained by the developer can be compared with signature to identify that the request comes from
Message push
When a common user sends a message to a public account, the server will POST the message to the entered URL. The structure is as follows:
Text message
toUser
fromUser
1348831860
text
this is a test
1234567890123456
Parameters |
Description |
ToUserName |
DeveloperNo. |
FromUserName |
Sender account (one OpenID) |
CreateTime |
Message creation time (integer) |
MsgType |
Text |
Content |
Text message content |
MsgId |
Message id, 64-bit integer |
Image message
toUser
fromUser
1348831860
image
this is a url]></PicUrl> <MsgId>1234567890123456</MsgId> </xml></pre><table border="1" cellspacing="0" cellpadding="4" align="center"><tbody><tr><th>参数</th><th>描述</th></tr><tr><td>ToUserName</td><td><strong>开发者</strong>号</td></tr><tr><td>FromUserName</td><td>发送方帐号(一个OpenID)</td></tr><tr><td>CreateTime</td><td>消息创建时间 (整型)</td></tr><tr><td>MsgType</td><td>image</td></tr><tr><td>PicUrl</td><td>图片链接</td></tr><tr><td>MsgId</td><td>消息id,64位整型</td></tr></tbody></table><p> </p><strong>地理位置消息</strong> <pre><xml><ToUserName><![CDATA[toUser
fromUser
1351776360
location
23.134521
113.358803
20
位置信息
1234567890123456
Parameters |
Description |
ToUserName |
DeveloperNo. |
FromUserName |
Sender account (one OpenID) |
CreateTime |
Message creation time (integer) |
MsgType |
Location |
Location_X |
Geographic location |
Location_Y |
Geographic longitude |
Scale |
Map zoom |
Label |
Geographic location information |
MsgId |
Message id, 64-bit integer |
Link message
toUser
fromUser
1351776360
link
<! [CDATA [Official website of the public platform]>
公众平台官网链接
url
1234567890123456
Parameters |
Description |
ToUserName |
Recipient number |
FromUserName |
Sender ID. if it is a common user, it is an OpenID. |
CreateTime |
Message creation time |
MsgType |
Message type, link |
Title |
Message title |
Description |
Message description |
Url |
Message link |
MsgId |
Message id, 64-bit integer |
Event push
Event push only supports version 4.5 and will be available soon.
toUser
fromUser
123456789
event
LOCATION
23.137466
113.352425
119.385040
Parameters |
Description |
ToUserName |
Recipient number |
FromUserName |
Sender ID. if it is a common user, it is an OpenID. |
CreateTime |
Message creation time |
MsgType |
Message type, event |
Event |
Event type, including ENTER and LOCATION) |
Latitude |
Geographic LOCATION dimension, which exists when the event type is LOCATION |
Longpolling |
Geographic longitude, which exists when the event type is LOCATION |
Precision |
Geographic LOCATION accuracy, which exists when the event type is LOCATION |
Message Reply
For each POST request, the developer returns a specific xml structure in the response packet to respond to the message (now supports replying to text, text, voice, video,MusicAnd perform star actions on received messages ).
The serverWithin five secondsIf no response is received, the connection will be disconnected.
The xml structure of the reply is as follows:
Reply text message
toUser
fromUser
12345678
text
content
0
Parameters |
Description |
ToUserName |
Recipient account (received OpenID) |
FromUserName |
Developer ID |
CreateTime |
Message creation time |
MsgType |
Text |
Content |
Reply message content |
FuncFlag |
The message received by the star when 0x0001 is marked. |
Reply music message
toUser
fromUser
12345678
music
<![CDATA[TITLE]]>
DESCRIPTION
MUSIC_Url
HQ_MUSIC_Url
0
Parameters |
Description |
ToUserName |
Recipient account (received OpenID) |
FromUserName |
Developer ID |
CreateTime |
Message creation time |
MsgType |
Music |
MusicUrl |
Music link |
HQMusicUrl |
High-quality music link, which is preferred for playing music in WIFI environments |
FuncFlag |
The message received by the star when 0x0001 is marked. |
Reply to text message
toUser
fromUser
12345678
news
2
<![CDATA[title1]]>
description1
picurl
url
<![CDATA[title]]>
description
picurl
url
1
Parameters |
Description |
ToUserName |
Recipient account (received OpenID) |
FromUserName |
Developer ID |
CreateTime |
Message creation time |
MsgType |
News |
ArticleCount |
Number of text and text messages, up to 10 |
Articles |
Multiple text messages. The first item is a large image by default. |
Title |
Text message title |
Description |
Text message description |
PicUrl |
Image links. JPG and PNG formats are supported. The effect is 40*320 and the image size is 80*80. the domain name that restricts Image links must be consistent with the Url in the basic information provided by the developer. |
Url |
Click the text message jump link |
Notes
- The user's OpenID is a fixed and unique string for a public account.
- Use Port 80
- The user follows the public account. the public platform server pushes a text message containing Hello2BizUser to a third-party server.