May 19, 2021 WeChat Mini Program Development Document
When the user and the small program customer service produce a specific action interaction (see the description below for the specific action list), WeChat will push the message data to the developer, the developer can call the customer service interface for a period of time (currently modified to 48 hours), through POST a JSON packet to send messages to ordinary users. This interface is mainly used for customer service and other human message processing links, convenient for developers to provide users with more quality services.
The list of actions currently allowed is as follows, and after different actions are triggered, the number of message bars and time limits issued by the allowed customer service interface are different. When the number of bar releases reaches the upper limit, you will receive an incorrect return code, see the return code description page:
User action | Allow a limit on the number of bars that can be issued | Time limit for issuance |
---|---|---|
The user enters the session via the customer service message button | 1 article | 1 minute |
The user sends a message | 5 | 48 hours |
The interface calls the request description
http请求方式: POST
https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
The JSON packets required for each message type are as follows:
Send a text message
{
"touser":"OPENID",
"msgtype":"text",
"text":
{
"content":"Hello World"
}
}
Send a picture message
{
"touser":"OPENID",
"msgtype":"image",
"image":
{
"media_id":"MEDIA_ID"
}
Send a link to the image
You can send a link to the picture at a time
{
"touser": "OPENID",
"msgtype": "link",
"link": {
"title": "Happy Day",
"description": "Is Really A Happy Day",
"url": "URL",
"thumb_url": "THUMB_URL"
}
}
Description of the parameters
Parameters | Whether it is necessary | Description |
---|---|---|
access_token | Is | Call the interface credentials |
touser | Is | Regular users (openid) |
msgtype | Is | Message type, text text, diagram link to link |
content | Is | The content of the text message |
media_id | Is | The media ID of the sent image is obtained by uploading the picture file through the New Footage interface. |
title | Yes | Photo link message title |
description | Yes | Photo link message |
Url | Is | A link that jumps after a link message is clicked |
picurl | Is | Image link message picture link, support JPG, PNG format, better results for large figure 640 X 320, small figure 80 X 80 |
The return code description
Parameters | Description |
---|---|
-1 | The system is busy, so please try again later |
0 | The request was successful |
40001 | The access_token the appSecret error when it was acquired, or access_token invalid. Ask the developer to carefully compare the correctness of AppSecret, or to see if the interface is being called for the appropriate applet |
40002 | The type of credential that is illegal |
40003 | Illegal OpenID, ask the developer to confirm that OpenID is the OpenID for other small programs |
45015 | The reply time exceeds the limit |
45047 | The number of down bars on the customer service interface exceeds the upper limit |
48001 | Api functionality is not authorized, please confirm that the small program has obtained the interface |