小程序appid:wx294d1797bdb7875b
请求地址:https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential
【access_token】结果:SNV8QqaJsZf5fUHy9K4CTWNUh68D3pm9IDj8erLi3hOCUXv1gLK2pTP_dFE6XmGkicGSiOwZLkjkz1wcgkybTbjd4zpzwhdWOrbKx-MNlSSRS7tQtbIKAOULcqSeGGkm7jAtxDrtuAWUWAHgABANRY
发送消息接口:https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=
请求数据:
{
"touser": "oC_0J5Z0AzBSuC9IJqkOqisF3Rsk",
"template_id": "UbwIM64L6mOnvuoTQ4srjDNyFkx49YfVLb9kG0qkIY8",
"page": "pages/index/index",
"miniprogram_state": "trial",
"lang": "zh_CN",
"data": {
"character_string1": {
"value": "ADWMP2933887762"
},
"thing3": {
"value": "张三"
},
"thing2": {
"value": "圆头粗跟短靴 黑色 36码 1双"
},
"thing4": {
"value": "江苏省无锡市江阴市高新区芙蓉路逐日大厦"
}
}
}
使用的模板
- 模板ID:UbwIM64L6mOnvuoTQ4srjDNyFkx49YfVLb9kG0qkIY8 (状态生效中)
- 模板编号:38506
- 标题:下单成功提醒
- 操作人:chenyuxiwx 2022-06-23 添加
- 详细内容
- 订单编号:{{character_string1.DATA}}
- 收货人名:{{thing3.DATA}}
- 商品:{{thing2.DATA}}
- 收货地址:{{thing4.DATA}}
前端订阅按钮
requestSubscribeMessage:function(){
wx.requestSubscribeMessage({
tmplIds: ['UbwIM64L6mOnvuoTQ4srjDNyFkx49YfVLb9kG0qkIY8'],
success (res) { }
})
},
一直报 {"errcode":48001,"errmsg":"api unauthorized rid: 62b4bd7c-5492160c-066221e6"}
怎么回事啊~~
你的发消息接口是公众的模板消息接口✗✗✗
https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=
需要换成这个小程序订阅消息接口↓↓↓↓
https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=
url改成https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=
试试
你用的接口是模板消息 不是订阅消息
参考该提交问题是否有帮助:https://developers.weixin.qq.com/community/develop/doc/0004a0fe5109400190ccf59fc5b000