微信服務(wù)號推送模板消息接口
更新時間:2015年08月03日 17:14:28 作者:-Xu-Zhao-
這篇文章主要介紹了微信服務(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)文章
C# 關(guān)于AppDomain的一些總結(jié)
這篇文章主要介紹了C# 關(guān)于AppDomain的一些總結(jié),幫助大家更好的理解和使用c#,感興趣的朋友可以了解下2021-02-02
C#將Excel中的數(shù)據(jù)轉(zhuǎn)換成DataSet
這篇文章主要介紹了C#將Excel中的數(shù)據(jù)轉(zhuǎn)換成DataSet的方法,非常簡單實用,從本人項目中提取出來的,推薦給大家,希望對大家學(xué)習(xí)C#能夠有所幫助。2015-03-03
C#實現(xiàn)添加/替換/提取或刪除Excel中的圖片
在Excel中插入與數(shù)據(jù)相關(guān)的圖片,能將關(guān)鍵數(shù)據(jù)或信息以更直觀的方式呈現(xiàn)出來,使文檔更加美觀,下面我們來看看如何在C#中實現(xiàn)添加/替換/提取或刪除Excel中的圖片吧2025-01-01

