微信公众号,发送模板消息

sendMessage(){
                var that = this;
                this.$axios({
                    method:"GET",
                    url:"/wxApi/cgi-bin/token?grant_type=client_credential&appid=wx97ae314497d666cc&secret=c908c74358240912dfe995474b3da54d"
                })
                .then(function(res){
                    console.log(res)
                    that.$axios({
                        method:"POST",
                        url:"/wxApi/cgi-bin/message/template/send?access_token="+res.data.access_token,
                        data:{
                            "touser":"oN0Eg6H9w0nB1C0Xc1fVK52lMW8Q", //用户的openid
                            "template_id":"DwjZ-7Ed0rZfVMyBdcxyz1I2ERPebF5Zuq_B98ihHpM",//模板id
                            "url":"http://10.0.0.10:8088/",//模板点击跳转的url
                            "appid":"wx97ae314497d666cc"  
                        }
                    })
                    .then(function(res){
                        console.log(res)
                        //alert(JSON.stringify(res))
                    })
                    .catch(function(err){
                        console.log(err)
                    })
                })
                .catch(function(err){
                    console.log(err)
                })
            }

官方文档接口:

 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html

 

posted @ 2020-12-09 10:30  秃头的铲屎官  Views(218)  Comments(0Edit  收藏  举报