Micro-channel subscription message applet

Micro letter backstage applet to add a subscription news service category under the current majority supports only a one-time subscription for updates. If there is no message in line with the template, you can apply custom templates, audit cycle is very long.

When filling out the template, you must pay attention to the parameter type.

Small program to send a subscription message must obtain an authorized user receives a message

Applet to be called

wx.requestSubscribeMessage ({ 
        tmplIds: [ 'RYdO0OyVwOmFJ5M9whapadK55agtmvWuumc_utFr7D4', 'bgEvkAITRuYbPET0IOPn8QPurVkXP7V6vjfPl7XDzrM' ], 
        Success (RES) { 
          the console.log (RES); 
          IF (res.RYdO0OyVwOmFJ5M9whapadK55agtmvWuumc_utFr7D4 == "Accept" ) { 
            the console.log ( 'has been authorized to receive the subscribed message " ); 
          } 
        } 
      })
View Code

Service-Terminal

 public void SendNewCouponRemind(string openid, string shopName, string couponTitle, string AddTime, int EndDays)
        {
            sub_postdata pdm = new sub_postdata();
            pdm.touser = openid;
            pdm.template_id = "bgEvkAITRuYbPET0IOPn8QPurVkXP7V6vjfPl7XDzrM";
            pdm.page = "/pages/discover/discover?p=3";
            sub_dataValue dv1 = new sub_dataValue();
            dv1.value = shopName;
            sub_dataValue dv2 = new sub_dataValue();
            dv2.value = couponTitle;
            sub_dataValue dv3 = new sub_dataValue();
            dv3.value = AddTime.ToString();
            sub_dataValue dv4 = new sub_dataValue();
            dv4.value = "领取后" + EndDays.ToString() + "日内";
            data_NewCouponRemind dm1 = new data_NewCouponRemind();
            dm1.thing7 = dv1;
            dm1.thing8 = dv2;
            dm1.date9 = dv3;
            dm1.thing10 = dv4;
            pdm.data = dm1;
            string pd = JsonConvert.SerializeObject(pdm, Formatting.None);
            SendMsg(pd, 2, 0, openid, couponTitle, shopName);
        }
View Code

 

 1  public void SendMsg(string contentJson, int Type, int UserGetCouponID, string openid, string CouponTitle, string ShopName)
 2         {
 3             // Hxzs.Common.LogUtil.WriteLog(contentJson);
 4             var l = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + getaccess_token();
 5             StringBuilder result = Hxzs.Common.HttpRequest.PostPageContent(l, "", contentJson, "UTF-8");
 6             if (!string.IsNullOrEmpty(result.ToString()))
 7             {
 8                 returnjson json = JsonConvert.DeserializeObject<returnjson>(result.ToString());
 9                 if (json.errcode == 0)
10                 {
11                     new Honszeal.Business.classes.Shop_Coupon.userBusiness().SaveSendWxMsgInfo(UserGetCouponID, openid, Type, CouponTitle, ShopName, contentJson);
12                 }
13                  Hxzs.Common.LogUtil.WriteLog(result.ToString());
14             }
15         }
View Code

Regardless of time, to allow a push transmittable once again.

Guess you like

Origin www.cnblogs.com/qq9493/p/12119339.html