#region 模版消息发送

        /// <summary>
        /// 发送公众号客服通知
        /// </summary>
        /// <param name="wxopenid"></param>
        /// <param name="first"></param>
        /// <param name="keyword1"></param>
        /// <param name="keyword2"></param>
        /// <param name="keyword3"></param>
        /// <param name="keyword4"></param>
        /// <param name="redirect_url">模版跳转路径 方法中有示例</param>
        /// <param name="remark"></param>
        /// <returns></returns>
        public static bool SendKefuNotifyMsg(CKXD.WeiXinManage.Model.wx_account accountModel, string Access_token, string wxopenid, string first, string keyword1, string keyword2, string keyword3, string redirect_url, string remark, string guid, string LogName)
        {
            CommonApi common = new CommonApi();
            string tempid = accountModel.WXA_KefuTem;
            string url = redirect_url;
            dynamic postData = new ExpandoObject();
            postData.touser = wxopenid;
            postData.template_id = tempid;
            postData.url = url == null ? "" : url;
            postData.topcolor = "#FF";
            postData.data = new ExpandoObject();
            var data = new[]
    {
     new Tuple<string, string, string>("first",first, "#173177"),
     new Tuple<string, string, string>("keyword1",keyword1, "#173177"),
     new Tuple<string, string, string>("keyword2",keyword2, "#173177"),
     new Tuple<string, string, string>("keyword3",keyword3, "#173177"),
     new Tuple<string, string, string>("remark",remark, "#173177")
    };
            var dataDict = (IDictionary<string, object>)postData.data;
            foreach (var item in data)
            {
                dataDict.Add(item.Item1, new { value = item.Item2, color = item.Item3 });
            }
            string json = Newtonsoft.Json.JsonConvert.SerializeObject((object)postData);
            string accessToken = Access_token;
            string strurl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken;
            string result = CommonApi.WXPostInfo(strurl, json, accountModel, guid, "weblog");
            T9.Util.LogUtil.WriteLog("SendKefuNotifyMsg-请求信息:" + strurl + "\r\n" + json, guid, LogName);
            T9.Util.LogUtil.WriteLog("SendKefuNotifyMsg-返回消息" + result, guid, LogName);
            return result.Contains("ok");
        }
        #endregion

版权声明:本文为lianjiangwuzhong原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/lianjiangwuzhong/article/details/119320775