예제 #1
0
        /// <summary>
        /// 发送模板消息
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="touser"></param>
        /// <param name="configParm"></param>
        /// <param name="contentList"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static TemPlateMessageResponse SendTemPlateMessage(string accessToken, string touser, string template_id, List <TemPlateMessageItem> msgitemlist, string url)
        {
            SendTemPlateMessage msg = new SendTemPlateMessage
            {
                data        = msgitemlist,
                template_id = template_id,
                touser      = touser,
                url         = url
            };

            return(SendTemPlateMessageOperate(accessToken, msg));
        }
예제 #2
0
        /// <summary>
        /// 发送模板消息
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static TemPlateMessageResponse SendTemPlateMessageOperate(string accessToken, SendTemPlateMessage msg)
        {
            IMpClient mpClient = new MpClient();

            Request.TemPlateMessage request = new Request.TemPlateMessage()
            {
                Method      = "POST",
                AccessToken = accessToken,
                ReqUrl      = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}",
                SendData    = msg.ToJsonString()
            };
            //LogHelper.WriteInfo("template_msg: ", msg.ToJsonString());
            TemPlateMessageResponse response = mpClient.Execute(request);

            if (response.IsError)
            {
                LogHelper.WriteDebug("发送模板消息响应", response.Body);
            }
            return(response);
        }