微信服务号推送模板消息接口
微信服务号现在用的比较火,用户可以通过微信号订阅信息,有时候会用到模板消息。下面贴上代码,有注释写的很详细。在此@access_token请调用https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=@appid&secret=@secret接口获取。
具体代码:
publicstaticvoidSend()
{
dynamicpostData=newExpandoObject();
postData.touser="OpenId";
postData.template_id="template_id";
postData.url=string.Empty;
postData.topcolor="#FF";
postData.data=newExpandoObject();
vardata=new[]
{
newTuple<string,string,string>("title","航班延误通知","#FF"),
newTuple<string,string,string>("trainNumber","分钟","#FF"),
newTuple<string,string,string>("fromto","上海-北京","#FF"),
newTuple<string,string,string>("formerTime","//::","#FF"),
newTuple<string,string,string>("Time","//::","#FF"),
newTuple<string,string,string>("number","分钟","#FF"),
newTuple<string,string,string>("reason","天气原因","#FF"),
newTuple<string,string,string>("remark","请关注我们的微信通知","#FF")
};
vardataDict=(IDictionary<string,object>)postData.data;
foreach(varitemindata)
{
dataDict.Add(item.Item,new{value=item.Item,color=item.Item});
}
stringjson=((object)postData).Serialize();
Console.WriteLine(json);
varr=NetUtils.CreateHttpResponse(@"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=@access_token",json);
Console.WriteLine(r);
}
以上就是本文针对微信服务号推送模板消息接口的全部内容,希望对大家有所帮助。
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短