微信服務(wù)號推送模板消息接口
微信服務(wù)號現(xiàn)在用的比較火,用戶可以通過微信號訂閱信息,有時候會用到模板消息。下面貼上代碼,有注釋寫的很詳細(xì)。在此@access_token 請調(diào)用 https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=@appid&secret=@secret 接口獲取。
具體代碼:
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", "http:// ::", "#FF"), new Tuple<string, string, string>("Time", "http:// ::", "#FF"), new Tuple<string, string, string>("number", "分鐘", "#FF"), new Tuple<string, string, string>("reason", "天氣原因", "#FF"), new Tuple<string, string, string>("remark", "請關(guān)注我們的微信通知", "#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); }
以上就是本文針對微信服務(wù)號推送模板消息接口的全部內(nèi)容,希望對大家有所幫助。
相關(guān)文章
WPF+ASP.NET SignalR實現(xiàn)動態(tài)折線圖的繪制
這篇文章將以一個簡單的動態(tài)折線圖示例,簡述如何通過ASP.NET SignalR實現(xiàn)后臺通知功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2023-01-01淺談C# 非模式窗體show()和模式窗體showdialog()的區(qū)別
下面小編就為大家?guī)硪黄獪\談C# 非模式窗體show()和模式窗體showdialog()的區(qū)別。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-07-07C#實現(xiàn)IDisposable接口釋放非托管資源
這篇文章主要為大家介紹了C#實現(xiàn)IDisposable接口釋放非托管資源,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05