您的位置:首页 > 其它

发送模板消息

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();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: