微信服務(wù)號(hào)推送模板消息接口
微信服務(wù)號(hào)現(xiàn)在用的比較火,用戶可以通過微信號(hào)訂閱信息,有時(shí)候會(huì)用到模板消息。下面貼上代碼,有注釋寫的很詳細(xì)。在此@access_token 請(qǐng)調(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", "請(qǐng)關(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);
}
以上就是本文針對(duì)微信服務(wù)號(hào)推送模板消息接口的全部內(nèi)容,希望對(duì)大家有所幫助。
- php版微信開發(fā)之接收消息,自動(dòng)判斷及回復(fù)相應(yīng)消息的方法
- 微信小程序-消息提示框?qū)嵗?/a>
- 微信小程序-詳解微信登陸、微信支付、模板消息
- 微信公眾號(hào)開發(fā)之文本消息自動(dòng)回復(fù)php代碼
- 微信公眾號(hào)開發(fā)之語音消息識(shí)別php代碼
- Java開發(fā)微信公眾號(hào)接收和被動(dòng)回復(fù)普通消息
- php實(shí)現(xiàn)微信公眾號(hào)主動(dòng)推送消息
- 基于python實(shí)現(xiàn)微信模板消息
- asp.net開發(fā)微信公眾平臺(tái)之獲取用戶消息并處理
- php實(shí)現(xiàn)發(fā)送微信模板消息的方法
- C#微信開發(fā)之接收 / 返回文本消息
相關(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的方法,非常簡單實(shí)用,從本人項(xiàng)目中提取出來的,推薦給大家,希望對(duì)大家學(xué)習(xí)C#能夠有所幫助。2015-03-03
C#實(shí)現(xiàn)添加/替換/提取或刪除Excel中的圖片
在Excel中插入與數(shù)據(jù)相關(guān)的圖片,能將關(guān)鍵數(shù)據(jù)或信息以更直觀的方式呈現(xiàn)出來,使文檔更加美觀,下面我們來看看如何在C#中實(shí)現(xiàn)添加/替換/提取或刪除Excel中的圖片吧2025-01-01
Windows Form 分頁 具體實(shí)現(xiàn)
其實(shí)功能實(shí)現(xiàn)很簡單。我做的是一個(gè)通用的分頁控件。項(xiàng)目時(shí)間很緊,可能有點(diǎn)粗糙。歡迎大家斧正。不說了直接貼代碼吧2013-12-12

