Exemplo n.º 1
0
        /// <summary>
        /// 获取模板列表
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        public static GetTemplateInfo GetTemplateInfo(string accessToken)
        {
            IMpClient mpClient = new MpClient();

            Request.TemPlateMessage request = new Request.TemPlateMessage()
            {
                Method      = "GET",
                AccessToken = accessToken,
                ReqUrl      = "https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token={0}",
            };
            TemPlateMessageResponse response = mpClient.Execute(request);

            if (response.IsError)
            {
                Utility.LogHelper.WriteDebug("获取模板列表响应", response.Body);
            }
            return(response.TemplateInfo);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 删除模板
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static TemPlateMessageResponse DeleteTemPlate(string accessToken, DeleteTemPlate msg)
        {
            IMpClient mpClient = new MpClient();

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

            if (response.IsError)
            {
                Utility.LogHelper.WriteDebug("删除模板", request.SendData);
                Utility.LogHelper.WriteDebug("删除模板响应", response.Body);
            }
            return(response);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 设置所属行业
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static TemPlateMessageResponse SetIndustry(string accessToken, SetIndustry msg)
        {
            IMpClient mpClient = new MpClient();

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

            if (response.IsError)
            {
                Utility.LogHelper.WriteDebug("模板消息设置所属行业", request.SendData);
                Utility.LogHelper.WriteDebug("模板消息设置所属行业响应", response.Body);
            }
            return(response);
        }