微信公众平台 模版消息


1.在模板库取模版编号,如TM00335

var msgData = new { template_id_short = "TM00335" };

  var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string json = serializer.Serialize((object)msgData);  var postUrl = "https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token="+access_token;
            string result = Helper.NetHelper.CallWebPage3(postUrl, json, ASCIIEncoding.UTF8, "text/json");
            Response.Write(result);



从result取到template_id


2.然后

 Dictionary<string, object> data = new Dictionary<string, object>();
            data.Add("first", new { value = "恭喜你积分成功!", color = "#173177" });
            data.Add("account", new { value = "***", color = "#173177" });

           。。。


   var msgData =
              new
              {
                  touser = "openid",
                  template_id = "   template_id",
                  topcolor = "#FF0000",
                  url = "",
                  data = data
              };


            //var msgData = new { template_id_short = "TM00335" };
            var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string json = serializer.Serialize((object)msgData);
            var postUrl = string.Format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=zA6sqpChVwf3UW8ZjuRdFFVZ8lBaonhwGMVN1XjGBCSDac-hIMTvRxjCbpsEYWBLde_xDeaWwwSJystWP08T846G9CdBche7L7lbFeA4Fsc");
         //  var postUrl = "https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=zA6sqpChVwf3UW8ZjuRdFFVZ8lBaonhwGMVN1XjGBCSDac-hIMTvRxjCbpsEYWBLde_xDeaWwwSJystWP08T846G9CdBche7L7lbFeA4Fsc";
            Helper.NetHelper.CallWebPage3(postUrl, json, ASCIIEncoding.UTF8, "text/json");


搞掂!这样对方微信就可以收到消息了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值