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();
}