/// <summary> /// 将用户请求的数据和系统回复的数据保存到数据库,数据落地 /// </summary> /// <param name="wid">微帐号主键Id,apiid</param> /// <param name="openid">请求的用户openid</param> /// <param name="requestType">用户请求的类型:文本消息:text 图片消息:image 地理位置消息:location 链接消息:link 事件:event</param> /// <param name="requestContent">用户请求的数据内容</param> /// <param name="responseType"> 系统回复的类型:文本消息:text ,图文消息:txtpic ,语音music, 地理位置消息:location 链接消息:link,未取到数据none</param> /// <param name="responseContent">系统回复的内容</param> /// <param name="ToUserName">由于取不到xml内容,我们将toUserName存入</param> /// <returns></returns> public static int Add(int wid, string openid, string requestType, string requestContent, string responseType, string responseContent, string ToUserName, string pickname, string image) { int ret = 0; try { XCWeiXin.Model.wx_response_BaseData model = new Model.wx_response_BaseData(); model.wid = wid; model.wx_openid = openid; model.requestType = requestType; model.requestContent = requestContent; model.responseType = responseType; model.reponseContent = responseContent; model.wx_xmlContent = ToUserName; model.createDate = DateTime.Now; model.extStr = pickname; model.extStr2 = image; ret = Add(model); } catch (Exception ex) { ret = 0; } return(ret); }
protected void Button1_Click(object sender, EventArgs e) { BLL.wx_response_BaseData bll = new BLL.wx_response_BaseData(); Model.wx_response_BaseData model = new Model.wx_response_BaseData(); string error = ""; XCWeiXin.WeiXinComm.WeiXinCRMComm cpp = new XCWeiXin.WeiXinComm.WeiXinCRMComm(); string accessToken = Token(); string openId = openid; string contents = TextBox1.Text; string URL_FORMAT = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}"; var data = new { touser = openId, msgtype = "text", text = new { content = contents } }; CommonJsonSend.Send(accessToken, URL_FORMAT, data, timeOut: 1000); model.id = int.Parse(id); model.reponseContent = TextBox1.Text; bll.updata(model); TextBox1.Text = ""; Response.Redirect("huifu.aspx?openid=" + openid + ""); }
/// <summary> /// 将用户请求的数据和系统回复的数据保存到数据库,数据落地 /// </summary> /// <param name="wid">微帐号主键Id,apiid</param> /// <param name="openid">请求的用户openid</param> /// <param name="requestType">用户请求的类型:文本消息:text 图片消息:image 地理位置消息:location 链接消息:link 事件:event</param> /// <param name="requestContent">用户请求的数据内容</param> /// <param name="responseType"> 系统回复的类型:文本消息:text ,图文消息:txtpic ,语音music, 地理位置消息:location 链接消息:link,未取到数据none</param> /// <param name="responseContent">系统回复的内容</param> /// <param name="ToUserName">由于取不到xml内容,我们将toUserName存入</param> /// <returns></returns> public static int Add(int wid, string openid, string requestType, string requestContent, string responseType, string responseContent, string ToUserName) { int ret = 0; try { WechatBuilder.Model.wx_response_BaseData model = new Model.wx_response_BaseData(); model.wid = wid; model.wx_openid = openid; model.requestType = requestType; model.requestContent = requestContent; model.responseType = responseType; model.reponseContent = responseContent; model.wx_xmlContent = ToUserName; model.createDate = DateTime.Now; ret = Add(model); } catch (Exception ex) { ret = 0; } return(ret); }
/// <summary> /// 将用户请求的数据和系统回复的数据保存到数据库,数据落地 /// </summary> /// <param name="wid">微帐号主键Id,apiid</param> /// <param name="openid">请求的用户openid</param> /// <param name="requestType">用户请求的类型:文本消息:text 图片消息:image 地理位置消息:location 链接消息:link 事件:event</param> /// <param name="requestContent">用户请求的数据内容</param> /// <param name="responseType"> 系统回复的类型:文本消息:text ,图文消息:txtpic ,语音music, 地理位置消息:location 链接消息:link,未取到数据none</param> /// <param name="responseContent">系统回复的内容</param> /// <param name="ToUserName">由于取不到xml内容,我们将toUserName存入</param> /// <returns></returns> public static int Add(int wid, string openid, string requestType, string requestContent, string responseType, string responseContent, string ToUserName) { int ret = 0; try { WechatBuilder.Model.wx_response_BaseData model = new Model.wx_response_BaseData(); model.wid = wid; model.wx_openid = openid; model.requestType = requestType; model.requestContent = requestContent; model.responseType = responseType; model.reponseContent = responseContent; model.wx_xmlContent = ToUserName; model.createDate = DateTime.Now; ret = Add(model); } catch (Exception ex) { ret = 0; } return ret; }
protected void btnSendout_Click(object sender, EventArgs e) { BLL.wx_crm_fodder cfBll = new BLL.wx_crm_fodder(); Model.wx_userweixin weixin = GetWeiXinCode(); //当前微信用户 Model.wx_crm_users cuModel = cuBll.GetModel(uid); //当前粉丝 string error = ""; string accessToken = WeiXinCRMComm.getAccessToken(weixin.id, out error); Model.wx_response_BaseData rc = new Model.wx_response_BaseData(); try { rc.createDate = DateTime.Now; rc.wid = weixin.id; rc.flag = 1; rc.rType = "客服回复"; rc.wx_openid = cuModel.openid;//当前粉丝的openid if (rblResponseType.SelectedItem.Value == "0") { //纯文本 //规则 if (this.txtContent.Text.Trim().Length == 0) { JscriptMsg("内容不能为空", "back", "Error"); return; } //添加内容 rc.reponseContent = txtContent.Text.Trim(); rc.responseType = "text"; SendText(accessToken, cuModel.openid, txtContent.Text.Trim()); } else if (rblResponseType.SelectedItem.Value == "1") { #region 图文的信息回复 //图文 //判断图片来自服务器或公网 string imgurl = this.txtImgUrl.Text; if (imgurl.IndexOf("http") < 0) { imgurl = MyCommFun.getWebSite() + imgurl; } //发送图文 List <Article> artList = new List <Article> { new Article() { Url = this.txtUrl.Text, PicUrl = imgurl, Title = this.txtTitle.Text, Description = this.txtNewsContent.Value }, }; SendNews(accessToken, cuModel.openid, artList); //添加内容 Model.wx_crm_fodder cfModel = new Model.wx_crm_fodder { scContent = this.txtNewsContent.Value, title = this.txtTitle.Text, picurl = imgurl, url = this.txtUrl.Text, createDate = DateTime.Now }; int res = cfBll.Add(cfModel); Dictionary <string, string> jsonDict = new Dictionary <string, string>(); jsonDict.Add("title", this.txtTitle.Text); jsonDict.Add("scContent", this.txtNewsContent.Value); jsonDict.Add("picurl", imgurl); jsonDict.Add("url", this.txtUrl.Text); jsonDict.Add("createDate", this.txtUrl.Text); rc.reponseContent = this.txtTitle.Text + ""; rc.responseType = "news"; #endregion } else if (rblResponseType.SelectedItem.Value == "2") { //语音 if (this.txtMusicTitle.Text.Trim().Length == 0) { JscriptMsg("音乐不能为空", "back", "Error"); return; } if (this.txtMusicFile.Text.Trim().Length == 0) { JscriptMsg("音乐链接不能为空", "back", "Error"); return; } //添加内容 rc.responseType = "voice"; rc.remark = txtMusicRemark.Text; SendVoice(accessToken, cuModel.openid, "Media_Id"); } rcBll.Add(rc); //AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "编辑" + ruleName); //记录日志 JscriptMsg("发送信息成功!", "talk.aspx?keywords=" + this.keywords + "&id=" + uid, "Success"); } catch (Exception) { JscriptMsg("发送信息失败!", "talk.aspx?keywords=" + this.keywords + "&id=" + uid, "Error"); return; } }