May 18, 2021 WeChat Mini Program Development Document
Access to WeChat city services, business parties need to ensure the function of the closed-loop service experience, need to access the messaging channel. Click here for city service messaging instructions.
How to request: POST Request Address: https://api.weixin.qq.com/cityservice/sendmsgdata?access_token=ACCESS_TOKEN
(1) Access_token access to the method please click here to view;
(2) When providing services through a small program, you need to use the small program user openid, and use the public number associated with the small program and requested the "message path" access_token
(1) After the successful application of the template, biz_template_id will be assigned, and according to the template push channels, respectively, provide style ID: result_page_style_id, deal_msg_style_id, card_style_id.
(2) When the interface is called, the following parameters in the json format are passed in via POST, the data type of all parameters is "string" and the character set uses UTC-8 by default.
The field description
Parameters | Description | Is it required |
---|---|---|
Openid | The user's unique identity | Required |
biz_template_id
|
The template id assigned to the public number by the city service | Required |
result_page_style_id
|
Results page style id | The results page is required |
deal_msg_style_id
|
Record style id | Required with record of work |
card_style_id
|
Page card style id | A paged card is required |
order_no
|
Order number, the record of the same order number is merged | Required |
url | Jump link, used for service notifications, result pages, and remind | In contraction page |
data | Template JSON data, where the Color field is only valid for the service notification | Required |
Parameter example
{
"openid":"OPENID",
"biz_template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
"result_page_style_id":"cUjfPSEtwasWQFsJ5PXo218PexBaHy5jg_peVDe4WkY",
"deal_msg_style_id":"cUjfPSEtwasWQFsJ5PXo24LeNjWbwMObXSHPNjVZ0uQ",
"card_style_id":"cUjfPSEtwasWQFsJ5PXo2z8LSM0Q6FH05DCerWEVkDs",
"order_no":"ORDER_NO",
"url":"http://weixin.qq.com/download",
"data":{
"first": {
"value":"恭喜你购买成功!",
"color":"#173177"
},
"keynote1":{
"value":"巧克力",
"color":"#173177"
},
"keynote2": {
"value":"39.8元",
"color":"#173177"
},
"keynote3": {
"value":"2014年9月22日",
"color":"#173177"
},
"remark":{
"value":"欢迎再次购买!",
"color":"#173177"
}
}
}
Note: Data encloses the data in the "data" field when it is an array.
3, return code description
After calling the message path interface, the JSON packet is returned:
Returns the result | Return code | Description |
---|---|---|
result_page_url
|
The result page url |
You need to jump to this url instead of the original service results page.
If no information is
result_page_style_id
the call
result_page_url
returned to empty.
|
errcode | 48001 | api is not authorized |
errcode | 40097 | 1. The argument is wrong. 2. Or openid does not come from a public number with "message path" api permissions |
errcode | 82020 | Users who do not pay attention to the public number have never accessed the service at the city service |
errcode | 82021 | Users who do not pay attention to the public number do not access the service through the city service within the last 30 days |
errcode | 82022 | Users who do not pay attention to the public number are issued more than 10 times in 30 days (more than 20 times in the medical industry) after accessing the service through the city service |
errcode | 82023 | Users who did not pay attention to the public number were sent out more than 5 times in an hour |
errcode | 82024 | order_no exceptions, such as all users' business order numbers using the same one |
errcode | 82025 | The URL is not valid |
errcode | 82026 | 1. The service is offline. 2. Or the service is under review and the audit period is more than 30 days |
Example of returning JSON packets in normal time:
{
"errcode":0,
"errmsg":"ok",
"result_page_url":"https://city.weixin.qq.com/static/resultpagenew.html?openid=ont-9vjAcIdSU-LgB7ubALAVJO9U&biz_template_id=ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY #wechat_redirect"
}
Note: If the result page style ID (or result_page_style_id) is not result_page_url the result is empty
Tips | Description |
---|---|
Chinese an error is displayed | The character set is not using utc8 |
The argument is wrong | The json parameter is wrong |
Not for me, the page failed to open | Non-personal openid; |
Please open it in WeChat | The page needs to be opened within WeChat |
System error | Other errors |