//<?xml version="1.0" encoding="utf-8"?> //<xml> // <ToUserName><![CDATA[olPjZjsXuQPJoV0HlruZkNzKc91E]]></ToUserName> // <FromUserName><![CDATA[gh_a96a4a619366]]></FromUserName> // <CreateTime>63497820384</CreateTime> // <MsgType>text</MsgType> // <Content><![CDATA[您刚才发送了文字信息:中文 //您还可以发送【位置】【图片】【语音】信息,查看不同格式的回复。 //SDK官方地址:http://weixin.senparc.com]]></Content> // <FuncFlag>0</FuncFlag> //</xml> /// <summary> /// 获取XDocument转换后的IResponseMessageBase实例(通常在反向读取日志的时候用到)。 /// 如果MsgType不存在,抛出UnknownRequestMsgTypeException异常 /// </summary> /// <returns></returns> public static IResponseMessageBase GetResponseEntity(XDocument doc) { ResponseMessageBase responseMessage = null; ResponseMsgType msgType; try { msgType = MsgTypeHelper.GetResponseMsgType(doc); switch (msgType) { case ResponseMsgType.Text: responseMessage = new ResponseMessageText(); break; case ResponseMsgType.Image: responseMessage = new ResponseMessageImage(); break; case ResponseMsgType.Voice: responseMessage = new ResponseMessageVoice(); break; case ResponseMsgType.Video: responseMessage = new ResponseMessageVideo(); break; case ResponseMsgType.Music: responseMessage = new ResponseMessageMusic(); break; case ResponseMsgType.News: responseMessage = new ResponseMessageNews(); break; case ResponseMsgType.Transfer_Customer_Service: responseMessage = new ResponseMessageTransfer_Customer_Service(); break; default: throw new UnknownRequestMsgTypeException(string.Format("MsgType:{0} 在ResponseMessageFactory中没有对应的处理程序!", msgType), new ArgumentOutOfRangeException()); } EntityHelper.FillEntityWithXml(responseMessage, doc); } catch (ArgumentException ex) { throw new WeixinException(string.Format("ResponseMessage转换出错!可能是MsgType不存在!,XML:{0}", doc.ToString()), ex); } return(responseMessage); }
/// <summary> /// ResponseMessageBase.CreateFromResponseXml(xml)的扩展方法 /// 从返回结果XML转换成IResponseMessageBase实体类 /// </summary> /// <param name="xml">返回给服务器的Response Xml</param> /// <returns></returns> public static ResponseMessageBase CreateResponseMessage(this string xml) { try { if (string.IsNullOrEmpty(xml)) { return(null); } var doc = XDocument.Parse(xml); ResponseMessageBase responseMessage = null; var msgType = (ResponseMsgType)Enum.Parse(typeof(ResponseMsgType), doc.Root.Element("MsgType").Value, true); switch (msgType) { case ResponseMsgType.Text: responseMessage = new ResponseMessageText(); break; case ResponseMsgType.Image: responseMessage = new ResponseMessageImage(); break; case ResponseMsgType.Voice: responseMessage = new ResponseMessageVoice(); break; case ResponseMsgType.Video: responseMessage = new ResponseMessageVideo(); break; case ResponseMsgType.Music: responseMessage = new ResponseMessageMusic(); break; case ResponseMsgType.News: responseMessage = new ResponseMessageNews(); break; } responseMessage.FillEntityWithXml(doc); return(responseMessage); } catch (Exception ex) { throw new WeiXinException("ResponseMessageBase.CreateFromResponseXml<T>过程发生异常!" + ex.Message, ex); } }
/// <summary> /// 获取响应类型实例,并初始化 /// </summary> /// <param name="requestMessage">请求</param> /// <param name="msgType">响应类型</param> /// <returns></returns> private static ResponseMessageBase CreateFromRequestMessage(RequestMessageBase requestMessage, ResponseMsgType msgType) { ResponseMessageBase responseMessage = null; try { switch (msgType) { case ResponseMsgType.Text: responseMessage = new ResponseMessageText(); break; case ResponseMsgType.News: responseMessage = new ResponseMessageNews(); break; case ResponseMsgType.Music: responseMessage = new ResponseMessageMusic(); break; case ResponseMsgType.Image: responseMessage = new ResponseMessageImage(); break; case ResponseMsgType.Voice: responseMessage = new ResponseMessageVoice(); break; case ResponseMsgType.Video: responseMessage = new ResponseMessageVideo(); break; default: throw new UnknownRequestMsgTypeException(string.Format("ResponseMsgType没有为 {0} 提供对应处理程序。", msgType), new ArgumentOutOfRangeException()); } responseMessage.ToUserName = requestMessage.FromUserName; responseMessage.FromUserName = requestMessage.ToUserName; responseMessage.CreateTime = DateTime.Now; //使用当前最新时间 } catch (Exception ex) { throw new WeiXinException("CreateFromRequestMessage过程发生异常", ex); } return(responseMessage); }
/// <summary> /// 获取响应类型实例,并初始化 /// </summary> /// <param name="msgType">响应类型</param> /// <returns></returns> private static IResponseMessageBase CreateFromRequestMessage(ResponseMsgType msgType) { IResponseMessageBase result = null; try { switch (msgType) { case ResponseMsgType.Text: result = new ResponseMessageText(); break; case ResponseMsgType.News: result = new ResponseMessageNews(); break; case ResponseMsgType.Music: result = new ResponseMessageMusic(); break; case ResponseMsgType.Image: result = new ResponseMessageImage(); break; case ResponseMsgType.Voice: result = new ResponseMessageVoice(); break; case ResponseMsgType.Video: result = new ResponseMessageVideo(); break; default: if (msgType != ResponseMsgType.NoResponse) { throw new Exception(string.Format("ResponseMsgType没有为 {0} 提供对应处理程序。", msgType), new ArgumentOutOfRangeException()); } result = new ResponseMessageBase(); break; } } catch (Exception inner) { throw new Exception("ResponseMessageFactory.CreateFromRequestMessage过程发生异常", inner); } return(result); }
public virtual ResponseMessageBase ToResponseMessage() { var res = new ResponseMessageNews(); foreach (var art in this.Articles) { var a = new Article() { Title = art.Title, Description = art.Description, PicUrl = art.PicUrl, Url = art.Url, }; res.Articles.Add(a); } return(res); }
public ResponseMessageNews GetVoteUrlResponse(string openid) { ResponseMessageNews news = base.CreateResponseMessage <ResponseMessageNews>(); Article item = new Article { Title = this.voteinfo.VoteTitle, Description = this.voteinfo.VoteTitle, Url = string.Concat(new object[] { this.voteinfo.HostUrl, "/WeiXin/VoteRedirect?voteid=", this.voteinfo.ID, "&openid=", openid }) }; news.Articles.Add(item); return(news); }
public async Task <bool> OnLocationMessageReceived(object sender, LocationMessageReceivedEventArgs e) { var messageHandler = sender as WeixinMessageHandler; var responseMessage = new ResponseMessageNews(); responseMessage.FromUserName = e.ToUserName; responseMessage.ToUserName = e.FromUserName; var markersList = new List <GoogleMapMarkers>(); markersList.Add(new GoogleMapMarkers() { Latitude = e.Latitude, Longitude = e.Longitude, Color = "red", Label = "S", Size = GoogleMapMarkerSize.Default, }); var mapSize = "480x600"; var mapUrl = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/, markersList, mapSize); responseMessage.Articles.Add(new Article() { Description = string.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}", e.Latitude, e.Longitude, e.Scale, e.Label), PicUrl = mapUrl, Title = "定位地点周边地图", Url = mapUrl }); responseMessage.Articles.Add(new Article() { Title = "AspNetCore.Weixin", Description = "AspNetCore.Weixin", PicUrl = "http://wx.demo.com/logo.jpg", Url = "http://wx.demo.com" }); await messageHandler.WriteAsync(responseMessage); return(true); }
public ResponseMessageNews GetBonusUrlResponse(string openid) { ResponseMessageNews news = base.CreateResponseMessage <ResponseMessageNews>(); Article item = new Article { Title = "核销后台", Description = "核销后台", Url = string.Concat(new object[] { this.voteinfo.HostUrl, "/Use/Index?voteid=", this.voteinfo.ID, "&openid=", openid }) }; news.Articles.Add(item); return(news); }
/// <summary> /// 从返回结果XML转换成IResponseMessageBase实体类(通常在反向读取日志的时候用到)。 /// </summary> /// <returns></returns> public static IResponseMessageBase GetResponseEntity(XDocument doc) { ResponseMessageBase val = null; try { ResponseMsgType responseMsgType = MsgTypeHelper.GetResponseMsgType(doc); switch (responseMsgType) { case ResponseMsgType.Text: val = new ResponseMessageText(); break; case ResponseMsgType.Image: val = new ResponseMessageImage(); break; case ResponseMsgType.Voice: val = new ResponseMessageVoice(); break; case ResponseMsgType.Video: val = new ResponseMessageVideo(); break; case ResponseMsgType.Music: val = new ResponseMessageMusic(); break; case ResponseMsgType.News: val = new ResponseMessageNews(); break; } val.FillEntityWithXml <ResponseMessageBase>(doc); return(val); } catch (Exception ex) { throw new Exception($"ResponseMessage转换出错!可能是MsgType不存在!,XML:{doc.ToString()}", ex); } }
public async Task <bool> OnEnterEventReceived(object sender, EnterEventReceivedEventArgs e) { var messageHandler = sender as WeixinMessageHandler; _logger.LogDebug("Subscribe: from:{0}", e.FromUserName); var responseMessage = new ResponseMessageNews(); responseMessage.FromUserName = e.ToUserName; responseMessage.ToUserName = e.FromUserName; responseMessage.Articles.Add(new Article() { Title = "欢迎进入AspNetCore.Weixin演示系统", Description = "由AspNetCore.Weixin提供", PicUrl = "https://mp.weixin.qq.com/cgi-bin/getimgdata?mode=large&source=file&fileId=200121314%3E&token=977619473&lang=zh_CN", Url = "http://wx.demo.com" }); await messageHandler.WriteAsync(responseMessage); return(true); }
public async Task <bool> OnSubscribeEventReceived(object sender, SubscribeEventReceivedEventArgs e) { var messageHandler = sender as WeixinMessageHandler; if (string.IsNullOrWhiteSpace(e.EventKey)) { _logger.LogDebug("Subscribe: from:{0}", e.FromUserName); var responseMessage = new ResponseMessageNews(); responseMessage.FromUserName = e.ToUserName; responseMessage.ToUserName = e.FromUserName; responseMessage.Articles.Add(new Article() { Title = "欢迎体验AspNetCore.Weixin演示系统", Description = "由AspNetCore.Weixin提供", PicUrl = "https://mp.weixin.qq.com/cgi-bin/getimgdata?mode=large&source=file&fileId=200121314%3E&token=977619473&lang=zh_CN", Url = "http://wx.demo.com" }); await messageHandler.WriteAsync(responseMessage); } else { _logger.LogDebug("Subscribe w/ scene({0}): {1}, {2}", e.FromUserName, e.EventKey, e.Ticket); var responseMessage = new ResponseMessageNews(); responseMessage.FromUserName = e.ToUserName; responseMessage.ToUserName = e.FromUserName; responseMessage.Articles.Add(new Article() { Title = "欢迎体验AspNetCore.Weixin演示系统", Description = "由AspNetCore.Weixin提供。此消息带场景({e.EventKey}, {e.Ticket})", PicUrl = "https://mp.weixin.qq.com/cgi-bin/getimgdata?mode=large&source=file&fileId=200121314%3E&token=977619473&lang=zh_CN", Url = "http://wx.demo.com" }); await messageHandler.WriteAsync(responseMessage); } return(true); }
/// <summary> /// 处理应答链的结果,转为SDK的结果 /// </summary> private IResponseMessageBase ResponseChainRequest_LevelForNode_ResultHandler(RC.IResponseMessage ret) { //根据应答链的处理结果,构造微信SDK的结果 IResponseMessageBase result = null; if (ret is RC.ResponseTextMessage) { ResponseMessageText result_text = base.CreateResponseMessage <ResponseMessageText>(); result_text.Content = ((RC.ResponseTextMessage)ret).Context; result = result_text; } else if (ret is RC.ResponseNewsResult) { ResponseMessageNews result_text = base.CreateResponseMessage <ResponseMessageNews>(); result_text.Articles = new System.Collections.Generic.List <Article>(); foreach (RC.ArticleCan item in ((RC.ResponseNewsResult)ret).ArticleList) { result_text.Articles.Add(new Article { Description = item.Description, PicUrl = item.PicUrl, Title = item.Title, Url = item.Url }); } result = result_text; } else if (ret is RC.ResponseArtificialCustomerResultMessage) { string[] accountList = ((RC.ResponseArtificialCustomerResultMessage)ret).AccountList; return(GetArtificialCustomerService(accountList)); } else if (ret is RC.ResponseRawResult) { result = this.ResponseChainRequest_LevelForNode_RawResultHandler((RC.ResponseRawResult)ret); } //返回结果 return(result); }
public void GetResponseEntityTest() { { //Text ResponseMessageText exceptResult = new ResponseMessageText() { ToUserName = "******", FromUserName = "******", CreateTime = DateTimeHelper.GetDateTimeFromXml(63497820384), //MsgType = ResponseMsgType.Text, Content = "文字信息", //FuncFlag = false }; var result = ResponseMessageFactory.GetResponseEntity(xmlText) as ResponseMessageText; Assert.AreEqual(exceptResult.ToUserName, result.ToUserName); Assert.AreEqual(exceptResult.CreateTime, result.CreateTime); Assert.AreEqual(exceptResult.Content, result.Content); } { //Image ResponseMessageNews exceptResult = new ResponseMessageNews() { //Articles = new List<Article>(), CreateTime = DateTimeHelper.GetDateTimeFromXml(63497821905), FromUserName = "******", ToUserName = "******", //FuncFlag = false, //MsgType = ResponseMsgType.News }; var result = ResponseMessageFactory.GetResponseEntity(xmlNews) as ResponseMessageNews; Assert.AreEqual(exceptResult.ToUserName, result.ToUserName); Assert.AreEqual(exceptResult.CreateTime, result.CreateTime); Assert.AreEqual(2, result.ArticleCount); Assert.AreEqual(result.Articles.Count, result.ArticleCount); } //TODO:测试语音和视频类型 { //Music ResponseMessageMusic exceptResult = new ResponseMessageMusic() { Music = new Music() { Title = "标题", Description = "说明", MusicUrl = "https://sdk.weixin.senparc.com/Content/music1.mp3", HQMusicUrl = "" }, CreateTime = DateTimeHelper.GetDateTimeFromXml(63497823450), FromUserName = "******", ToUserName = "******", //FuncFlag = false, //MsgType = ResponseMsgType.Music }; var result = ResponseMessageFactory.GetResponseEntity(xmlMusic) as ResponseMessageMusic; Assert.AreEqual(exceptResult.ToUserName, result.ToUserName); Assert.AreEqual(exceptResult.CreateTime, result.CreateTime); //Assert.AreEqual(exceptResult.Music, result.Music); } }
//加载文件 private static void LoadConfig() { var tempResponse = new List <ResponseModel>(); var xml = new XmlDocument(); xml.Load(ConfigFile); var items = xml.SelectNodes("/Events/Item"); for (var i = 0; i < items.Count; i++) { var strType = (from XmlNode node in items[i].ChildNodes where node.Name == "MsgType" select node.InnerText).FirstOrDefault(); if (strType == null) { throw new Exception("responseMessage.xml文件配置有误 MsgType 不能为空!"); } ResponseMsgType msgType; if (!Enum.TryParse(strType, true, out msgType)) { throw new Exception("responseMessage.xml文件配置有误 MsgType 不属于指定的类型!"); } IResponseMessageBase responseMessage; switch (msgType) { case ResponseMsgType.Text: responseMessage = new ResponseMessageText { Content = (from XmlNode node in items[i].ChildNodes where node.Name == "Content" select node.InnerText).FirstOrDefault() }; break; case ResponseMsgType.Image: responseMessage = new ResponseMessageImage { Image = new Image { MediaId = (from XmlNode node in items[i].ChildNodes where node.Name == "MediaId" select node.InnerText).FirstOrDefault() } }; break; case ResponseMsgType.Voice: responseMessage = new ResponseMessageVoice { Voice = new Voice { MediaId = (from XmlNode node in items[i].ChildNodes where node.Name == "MediaId" select node.InnerText).FirstOrDefault() } }; break; case ResponseMsgType.Video: responseMessage = new ResponseMessageVideo { Video = new Video { Title = (from XmlNode node in items[i].ChildNodes where node.Name == "Title" select node.InnerText).FirstOrDefault(), Description = (from XmlNode node in items[i].ChildNodes where node.Name == "Description" select node.InnerText).FirstOrDefault(), MediaId = (from XmlNode node in items[i].ChildNodes where node.Name == "MediaId" select node.InnerText).FirstOrDefault() } }; break; case ResponseMsgType.Music: responseMessage = new ResponseMessageMusic { Music = new Music { Description = (from XmlNode node in items[i].ChildNodes where node.Name == "Description" select node.InnerText).FirstOrDefault(), HQMusicUrl = (from XmlNode node in items[i].ChildNodes where node.Name == "HQMusicUrl" select node.InnerText).FirstOrDefault(), MusicUrl = (from XmlNode node in items[i].ChildNodes where node.Name == "MusicUrl" select node.InnerText).FirstOrDefault(), ThumbMediaId = (from XmlNode node in items[i].ChildNodes where node.Name == "ThumbMediaId" select node.InnerText).FirstOrDefault(), Title = (from XmlNode node in items[i].ChildNodes where node.Name == "Title" select node.InnerText).FirstOrDefault() } }; break; case ResponseMsgType.News: var selects = items[i].SelectNodes("Article"); var articles = new List <Article>(); for (var j = 0; j < selects.Count; j++) { var url = ( from XmlNode node in selects[j].ChildNodes where node.Name == "Url" select node.InnerText).FirstOrDefault(); articles.Add(new Article { Description = (from XmlNode node in selects[j].ChildNodes where node.Name == "Description" select node.InnerText).FirstOrDefault(), PicUrl = (from XmlNode node in selects[j].ChildNodes where node.Name == "PicUrl" select node.InnerText).FirstOrDefault(), Title = (from XmlNode node in selects[j].ChildNodes where node.Name == "Title" select node.InnerText).FirstOrDefault(), //Url = WeixinCommon.GetAuthorizeUserInfoUrl(url) Url = url }); } responseMessage = new ResponseMessageNews { Articles = articles }; break; default: continue; } var eventKey = (from XmlNode node in items[i].ChildNodes where node.Name == "EventKey" select node.InnerText).FirstOrDefault(); tempResponse.Add(new ResponseModel { EventKey = eventKey, MsgType = msgType, ResponseMessage = responseMessage }); } _responseList = tempResponse; _isChanging = false; }
public ActionResult PostQuickResponse(string openId, List <NewsInfoView> newsList) { try { var news = newsList[0]; if ("video".Equals(news.NewsCate)) { news.ImageContent = SaveBase64ImageToServer(news.ImageContent); } SysWechatConfig wechat = WeChatCommonService.lstSysWeChatConfig.Find(p => p.Id == news.AppId && !p.IsCorp.Value); if (wechat == null) { return(Json(new { results = new { Data = 500 } })); } ResponseMessageBase response = null; var lstArticles = GetArticleList(newsList, false, news.NewsCate, null, false); //发送消息 WechatCommonMP.SendMsg(news.NewsCate, "", lstArticles, "", new string[] { openId }, null, true); switch (news.NewsCate) { case "text": response = new ResponseMessageText() { Content = news.NewsContent }; //returnResult = CustomApi.SendText(wechat.WeixinAppId, wechat.WeixinCorpSecret, openId, news.NewsContent); break; case "news": //var lstArticles = GetArticleList(newsList, false); //List<NewsModel> articles = new List<NewsModel>(); //string host = CommonService.GetSysConfig("Content Server", ""); //if (host.EndsWith("/")) //{ // host = host.Substring(0, host.Length - 1); //} //for (int i = 0; i < lstArticles.Count; i++) //{ // var item = lstArticles[i]; // var filePath = Server.MapPath("~/") + item.ImageCoverUrl.Insert(item.ImageCoverUrl.LastIndexOf('.'), "_T"); // if (0 == i) // { // filePath = filePath.Replace("_T", "_B"); // } // var ret0 = Innocellence.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(wechat.WeixinAppId, wechat.WeixinCorpSecret, Weixin.MP.UploadMediaFileType.thumb, filePath); // var picUrl = (host + item.ImageCoverUrl).Replace("\\", "/"); // var url = string.Format("{0}/MPNews/ArticleInfo/WxDetail/{1}?wechatid={2}&isPreview={3}", host, item.Id, item.AppId, false); // articles.Add(new NewsModel() { title = item.ArticleTitle, content = WechatCommonMP.ImageConvert(item.ArticleContent, wechat.Id), thumb_url = picUrl, thumb_media_id = ret0.thumb_media_id, content_source_url = url }); //} //var ret = Innocellence.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryNews(wechat.WeixinAppId, wechat.WeixinCorpSecret, 10000, articles.ToArray()); //returnResult = CustomApi.SendMpNews(wechat.WeixinAppId, wechat.WeixinCorpSecret, openId, ret.media_id); string _newsHost = Infrastructure.Web.Domain.Service.CommonService.GetSysConfig("WeChatUrl", ""); response = new ResponseMessageNews() { Articles = lstArticles.Select(a => new Article() { Title = a.ArticleTitle, Url = string.Format("{0}/{3}/ArticleInfo/wxdetail/{1}?wechatid={2}&isAutoReply={4}", _newsHost, a.Id, news.AppId, "mpnews", 0),// _newsHost + "/News/ArticleInfo/wxdetail/" + a.Id + "?wechatid=" + appId, PicUrl = _newsHost + a.ImageCoverUrl, Description = a.ArticleComment }).ToList() }; break; case "image": //WechatCommon.GetMediaInfo(AutoReplyContentEnum.IMAGE, news, news.AppId); //returnResult = CustomApi.SendImage(wechat.WeixinAppId, wechat.WeixinCorpSecret, openId, news.MediaId); response = new ResponseMessageImage() { Image = new Weixin.Entities.Image() { MediaId = news.MediaId } }; break; case "video": //WechatCommon.GetMediaInfo(AutoReplyContentEnum.VIDEO, news, news.AppId); ////var ret1 = Innocellence.Weixin.MP.AdvancedAPIs.GroupMessageApi.GetOpenIdVideoMediaIdResult(wechat.WeixinAppId, wechat.WeixinCorpSecret, news.MediaId, news.NewsTitle, news.NewsComment); ////news.MediaId = ret1.media_id; ////news.MediaCreateTime = ret1.created_at; //returnResult = CustomApi.SendVideo(wechat.WeixinAppId, wechat.WeixinCorpSecret, openId, news.MediaId, news.NewsTitle, news.NewsComment); response = new ResponseMessageVideo() { Video = new Video() { MediaId = news.MediaId } }; break; case "voice": //WechatCommon.GetMediaInfo(AutoReplyContentEnum.VOICE, news, news.AppId); //returnResult = CustomApi.SendVoice(wechat.WeixinAppId, wechat.WeixinCorpSecret, openId, news.MediaId); response = new ResponseMessageVoice() { Voice = new Voice() { MediaId = news.MediaId } }; break; default: throw new Exception("Invalid media type."); } //var user = _WechatMPUserService.GetUserByOpenId(openId); response.ToUserName = openId; var task = _WeChatUserRequestMessageLogHandler.WriteResponseLogMP(new List <Innocellence.Weixin.Entities.IResponseMessageBase> { response }, news.AppId.ToString(), false); return(Json(new { results = new { Data = 200, Object = task.Result } })); } catch (Exception e) { _Logger.Error(e, "An error occurred while PostQuickResponse."); return(Json(new { results = new { Data = 500, Message = e.Message } })); } }
public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Click requestMessage) { IResponseMessageBase base2 = null; switch (requestMessage.EventKey) { case "lobby": return(this.GetUrlResponse(requestMessage.FromUserName)); case "OneClick": { ResponseMessageText text = base.CreateResponseMessage <ResponseMessageText>(); base2 = text; text.Content = "您点击了底部按钮。\r\n为了测试微信软件换行bug的应对措施,这里做了一个——\r\n换行"; return(base2); } case "SubClickRoot_Text": { ResponseMessageText text2 = base.CreateResponseMessage <ResponseMessageText>(); base2 = text2; text2.Content = "您点击了子菜单按钮。"; return(base2); } case "SubClickRoot_News": { ResponseMessageNews news = base.CreateResponseMessage <ResponseMessageNews>(); base2 = news; Article item = new Article { Title = "您点击了子菜单图文按钮", Description = "您点击了子菜单图文按钮,这是一条图文信息。", PicUrl = "http://sdk.weixin.senparc.com/Images/qrcode.jpg", Url = "http://sdk.weixin.senparc.com" }; news.Articles.Add(item); return(base2); } case "SubClickRoot_Music": { UploadTemporaryMediaResult result = MediaApi.UploadTemporaryMedia(AccessTokenContainer.TryGetAccessToken(this.appId, this.appSecret, false), UploadMediaFileType.thumb, Server.GetMapPath("~/Images/Logo.jpg"), 0x2710); ResponseMessageMusic music = base.CreateResponseMessage <ResponseMessageMusic>(); base2 = music; music.Music.Title = "天籁之音"; music.Music.Description = "真的是天籁之音"; music.Music.MusicUrl = "http://sdk.weixin.senparc.com/Content/music1.mp3"; music.Music.HQMusicUrl = "http://sdk.weixin.senparc.com/Content/music1.mp3"; music.Music.ThumbMediaId = result.thumb_media_id; return(base2); } case "SubClickRoot_Image": { UploadTemporaryMediaResult result2 = MediaApi.UploadTemporaryMedia(AccessTokenContainer.TryGetAccessToken(this.appId, this.appSecret, false), UploadMediaFileType.image, Server.GetMapPath("~/Images/Logo.jpg"), 0x2710); ResponseMessageImage image = base.CreateResponseMessage <ResponseMessageImage>(); base2 = image; image.Image.MediaId = result2.media_id; return(base2); } case "OAuth": { ResponseMessageNews news2 = base.CreateResponseMessage <ResponseMessageNews>(); Article article2 = new Article { Title = "OAuth2.0测试", Description = "选择下面两种不同的方式进行测试,区别在于授权成功后,最后停留的页面。" }; news2.Articles.Add(article2); Article article3 = new Article { Title = "OAuth2.0测试(不带returnUrl),测试环境可使用", Description = "OAuth2.0测试(不带returnUrl)", Url = "http://sdk.weixin.senparc.com/oauth2", PicUrl = "http://sdk.weixin.senparc.com/Images/qrcode.jpg" }; news2.Articles.Add(article3); string url = "/OAuth2/TestReturnUrl"; Article article4 = new Article { Title = "OAuth2.0测试(带returnUrl),生产环境强烈推荐使用", Description = "OAuth2.0测试(带returnUrl)", Url = "http://sdk.weixin.senparc.com/oauth2?returnUrl=" + url.UrlEncode(), PicUrl = "http://sdk.weixin.senparc.com/Images/qrcode.jpg" }; news2.Articles.Add(article4); return(news2); } case "Description": { ResponseMessageText text3 = base.CreateResponseMessage <ResponseMessageText>(); text3.Content = this.GetWelcomeInfo(); return(text3); } case "SubClickRoot_PicPhotoOrAlbum": { ResponseMessageText text4 = base.CreateResponseMessage <ResponseMessageText>(); base2 = text4; text4.Content = "您点击了【微信拍照】按钮。系统将会弹出拍照或者相册发图。"; return(base2); } case "SubClickRoot_ScancodePush": { ResponseMessageText text5 = base.CreateResponseMessage <ResponseMessageText>(); base2 = text5; text5.Content = "您点击了【微信扫码】按钮。"; return(base2); } case "ConditionalMenu_Male": { ResponseMessageText text6 = base.CreateResponseMessage <ResponseMessageText>(); base2 = text6; text6.Content = "您点击了个性化菜单按钮,您的微信性别设置为:男。"; return(base2); } case "ConditionalMenu_Femle": { ResponseMessageText text7 = base.CreateResponseMessage <ResponseMessageText>(); base2 = text7; text7.Content = "您点击了个性化菜单按钮,您的微信性别设置为:女。"; return(base2); } } ResponseMessageText text8 = base.CreateResponseMessage <ResponseMessageText>(); text8.Content = "您点击了按钮,EventKey:" + requestMessage.EventKey; return(text8); }