当前位置: 移动技术网 > IT编程>开发语言>c# > 微信服务号推送模板消息接口

微信服务号推送模板消息接口

2019年07月18日  | 移动技术网IT编程  | 我要评论

微信服务号现在用的比较火,用户可以通过微信号订阅信息,有时候会用到模板消息。下面贴上代码,有注释写的很详细。在此@access_token 请调用 接口获取。

具体代码:

public static void send()
   {
    dynamic postdata = new expandoobject();
    postdata.touser = "openid";
    postdata.template_id = "template_id";
    postdata.url = string.empty;
    postdata.topcolor = "#ff";
    postdata.data = new expandoobject();
    var data = new[]
    {
     new tuple<string, string, string>("title", "航班延误通知", "#ff"),
     new tuple<string, string, string>("trainnumber", "分钟", "#ff"),
     new tuple<string, string, string>("fromto", "上海-北京", "#ff"),
     new tuple<string, string, string>("formertime", "// ::", "#ff"),
     new tuple<string, string, string>("time", "// ::", "#ff"),
     new tuple<string, string, string>("number", "分钟", "#ff"),
     new tuple<string, string, string>("reason", "天气原因", "#ff"),
     new tuple<string, string, string>("remark", "请关注我们的微信通知", "#ff")
    };
    var datadict = (idictionary<string, object>)postdata.data;
    foreach (var item in data)
    {
     datadict.add(item.item, new { value = item.item, color = item.item });
    }
    string json = ((object)postdata).serialize();
    console.writeline(json);
    var r = netutils.createhttpresponse(@"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=@access_token", json);
    console.writeline(r);
   }

以上就是本文针对微信服务号推送模板消息接口的全部内容,希望对大家有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网