コード例 #1
0
ファイル: TemplateAPI.cs プロジェクト: amwtke/bkwecaht
 /// <summary>
 /// 模板消息接口
 /// </summary>
 /// <param name="accessTokenOrAppId"></param>
 /// <param name="openId"></param>
 /// <param name="templateId"></param>
 /// <param name="topcolor"></param>
 /// <param name="url"></param>
 /// <param name="data"></param>
 /// <param name="timeOut">代理请求超时时间(毫秒)</param>
 /// <returns></returns>
 public static SendTemplateMessageResult SendTemplateMessage(string accessToken, string openId, string templateId, string topcolor, string url, object data, int timeOut = Config.TIME_OUT)
 {
     const string urlFormat = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
     var msgData = new TempleteModel()
     {
         touser = openId,
         template_id = templateId,
         topcolor = topcolor,
         url = url,
         data = data
     };
     return Senparc.Weixin.CommonAPIs.CommonJsonSend.Send<SendTemplateMessageResult>(accessToken, urlFormat, msgData, timeOut: timeOut);
 }
コード例 #2
0
 /// <summary>
 /// 模板消息接口
 /// </summary>
 /// <param name="accessTokenOrAppId"></param>
 /// <param name="openId"></param>
 /// <param name="templateId"></param>
 /// <param name="topcolor"></param>
 /// <param name="url"></param>
 /// <param name="data"></param>
 /// <param name="timeOut">代理请求超时时间(毫秒)</param>
 /// <returns></returns>
 public static SendTemplateMessageResult SendTemplateMessage(string accessTokenOrAppId, string openId, string templateId, string topcolor, string url, object data, int timeOut = Config.TIME_OUT)
 {
     return(ApiHandlerWapper.TryCommonApi(accessToken =>
     {
         const string urlFormat = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
         var msgData = new TempleteModel()
         {
             touser = openId,
             template_id = templateId,
             topcolor = topcolor,
             url = url,
             data = data
         };
         return CommonJsonSend.Send <SendTemplateMessageResult>(accessToken, urlFormat, msgData, timeOut: timeOut);
     }, accessTokenOrAppId));
 }
コード例 #3
0
        /// <summary>
        /// 模板消息接口
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="openId"></param>
        /// <param name="templateId"></param>
        /// <param name="topcolor"></param>
        /// <param name="url"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static SendTemplateMessageResult SendTemplateMessage(string accessToken, string openId, string templateId, string topcolor, string url, object data)
        {
            string urlFormat = string.Format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}", accessToken);
            var    msgData   = new TempleteModel()
            {
                touser      = openId,
                template_id = templateId,
                topcolor    = topcolor,
                url         = url,
                data        = data
            };
            JavaScriptSerializer js = new JavaScriptSerializer();
            string jsonData         = js.Serialize(msgData);

            return(HttpUtility.PostJson <SendTemplateMessageResult>(urlFormat, jsonData));
        }
コード例 #4
0
ファイル: TemplateApi.cs プロジェクト: ofood/WeChat
 public static async Task <SendTemplateMessageResult> SendTemplateMessageAsync(string accessTokenOrAppId, string openId, string templateId, string url, object data, TempleteModel_MiniProgram miniProgram = null, int timeOut = WxConfig.TIME_OUT)
 {
     return(await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
     {
         string urlFormat = WxConfig.ApiMpHost + "/cgi-bin/message/template/send?access_token={0}";
         var msgData = new TempleteModel()
         {
             touser = openId,
             template_id = templateId,
             // topcolor = topcolor,
             url = url,
             miniprogram = miniProgram,
             data = data,
         };
         return await CommonJsonSend.SendAsync <SendTemplateMessageResult>(accessToken, urlFormat, msgData, timeOut: timeOut);
     }, accessTokenOrAppId));
 }
コード例 #5
0
ファイル: TemplateApi.cs プロジェクト: ofood/WeChat
        public static SendTemplateMessageResult SendTemplateMessage(string accessTokenOrAppId, string openId, string templateId, string url, object data, TempleteModel_MiniProgram miniProgram = null, int timeOut = WxConfig.TIME_OUT)
        {
            //文档:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1500374289_66bvB

            return(ApiHandlerWapper.TryCommonApi(accessToken =>
            {
                string urlFormat = WxConfig.ApiMpHost + "/cgi-bin/message/template/send?access_token={0}";
                var msgData = new TempleteModel()
                {
                    touser = openId,
                    template_id = templateId,
                    // topcolor = topcolor,
                    url = url,
                    miniprogram = miniProgram,
                    data = data,
                };
                return CommonJsonSend.Send <SendTemplateMessageResult>(accessToken, urlFormat, msgData, timeOut: timeOut);
            }, accessTokenOrAppId));
        }
コード例 #6
0
        public static WxTemplateMessageResult SendTemplateMessage(string accessTocken, TempleteModel TempleteModel)
        {
            string urlFormat = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";

            return(WxTemplateHelp.WxCommonSend <WxTemplateMessageResult>(accessTocken, urlFormat, TempleteModel, CommonJsonSendType.POST));
        }
コード例 #7
0
ファイル: TemplateApi.cs プロジェクト: JeffreySu/WeiXinMPSDK
        /// <summary>
        /// 【异步方法】模板消息接口
        /// </summary>
        /// <param name="accessTokenOrAppId"></param>
        /// <param name="openId"></param>
        /// <param name="templateId"></param>
        /// <param name="url"></param>
        /// <param name="data"></param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// <returns></returns>
        public static async Task<SendTemplateMessageResult> SendTemplateMessageAsync(string accessTokenOrAppId, string openId, string templateId, string url, object data, int timeOut = Config.TIME_OUT)
        {
            return await ApiHandlerWapper.TryCommonApiAsync(accessToken =>
            {
                const string urlFormat = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";
                var msgData = new TempleteModel()
                {
                    touser = openId,
                    template_id = templateId,
                   // topcolor = topcolor,
                    url = url,
                    data = data
                };
                return Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SendTemplateMessageResult>(accessToken, urlFormat, msgData, timeOut: timeOut);

            }, accessTokenOrAppId);
        }