发送模板消息
2015-11-30 16:46
344 查看
public ActionResult SendMsg()
{
string token = getAccessToken(true, "gh9ca2");
string templateID = "ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY";
dynamic postData = new ExpandoObject();
postData.touser = "OpenId";
postData.template_id = templateID;
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>("remark", "感谢您关注我们", "#FF")
};
var dataDict = (IDictionary<string, object>)postData.data;
foreach (var item in data)
{
dataDict.Add(item.Item1, new { value = item.Item2, color = item.Item3 });
}
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
string json = jsonSerializer.Serialize((object)postData);
//string url = string.Format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}", token);
string url = "";
var result = Post("url", json);
return View();
}
{
string token = getAccessToken(true, "gh9ca2");
string templateID = "ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY";
dynamic postData = new ExpandoObject();
postData.touser = "OpenId";
postData.template_id = templateID;
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>("remark", "感谢您关注我们", "#FF")
};
var dataDict = (IDictionary<string, object>)postData.data;
foreach (var item in data)
{
dataDict.Add(item.Item1, new { value = item.Item2, color = item.Item3 });
}
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
string json = jsonSerializer.Serialize((object)postData);
//string url = string.Format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}", token);
string url = "";
var result = Post("url", json);
return View();
}
相关文章推荐
- win2003中IIS上传大附件下载附件超时等设置参考
- SpringMVC 中 jsp 页面对 Controller 返回数据的使用
- 第十二周项目4-利用遍历思想求解图问题(1-5)
- 第十四周项目---平衡二叉树
- 第十四周--项目1验证分块查找
- AutoLayout中的Content Hugging 和 Content Compression Resistance
- 对python装饰器的理解(来自百度经验,侵删)
- 第13周-项目4-项目4 - 利用遍历思想求解图问题
- 十大Material Design开源项目
- leader/follower多线程模型
- 博客
- RecyclerView分割线
- java压缩文件和解压文件
- java常用工具类UploadHelper
- 算法系统学习-1排序-快速排序
- 【C语言提高10】【指针铁律】铁律4:应用指针必须和函数调用相结合(指针做函数参数)
- Junit的使用
- 14周-项目2 - 二叉树排序树中查找的路径
- 第13周项目2
- 第十二周--数据结构--图的遍历