发送模板消息

 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<stringstringstring>("title""商机提醒通知""#FF"),
                 new Tuple<stringstringstring>("trainNumber""通知主体""#FF"),
                 new Tuple<stringstringstring>("remark""感谢您关注我们""#FF")
                };
            var dataDict = (IDictionary<stringobject>)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();
        }
posted @ 2015-11-30 16:46  You最温暖的港湾  阅读(405)  评论(0编辑  收藏  举报