asp.net微信开发(消息应答)(4)

/// <summary> /// 发送关注时的图文消息 /// </summary> /// <param></param> private void SendWelComeMsg(RequestXML requestXML) { String responseContent = String.Empty; string newdate = DateTime.Now.Subtract(new DateTime(1970, 1, 1, 8, 0, 0)).TotalSeconds.ToString(); string PUrlfileName = "http://www.deqiaohr.com.cn/weixin/welcome.jpg"; responseContent = string.Format(Message_News_Main, requestXML.FromUserName, requestXML.ToUserName, newdate, "1", string.Format(Message_News_Item, "欢迎关注德桥员工服务中心", "苏州德桥人力资源创立于2002年...", PUrlfileName, "http://www.deqiaohr.com.cn/weixin/WxGsjianjie.aspx")); HttpContext.Current.Response.ContentType = "text/xml"; HttpContext.Current.Response.ContentEncoding = Encoding.UTF8; HttpContext.Current.Response.Write(responseContent); HttpContext.Current.Response.End(); }

Message_News_Main 和Message_News_Item是图文消息格式化

/// <summary> /// 返回图文消息主体 /// </summary> public static string Message_News_Main { get { return @"<xml> <ToUserName><![CDATA[{0}]]></ToUserName> <FromUserName><![CDATA[{1}]]></FromUserName> <CreateTime>{2}</CreateTime> <MsgType><![CDATA[news]]></MsgType> <ArticleCount>{3}</ArticleCount> <Articles> {4} </Articles> </xml> "; } } /// <summary> /// 返回图文消息项 /// </summary> public static string Message_News_Item { get { return @"<item> <Title><![CDATA[{0}]]></Title> <Description><![CDATA[{1}]]></Description> <PicUrl><![CDATA[{2}]]></PicUrl> <Url><![CDATA[{3}]]></Url> </item>"; } } /// <summary> /// 发送响应语音识别结果 /// </summary> /// <param></param> private void SendVoiceMsg(RequestXML requestXML) { string responseContent = FormatTextXML(requestXML.FromUserName, requestXML.ToUserName, "您刚才说的语音消息识别结果为:" + requestXML.Recognition.ToString()); HttpContext.Current.Response.ContentType = "text/xml"; HttpContext.Current.Response.ContentEncoding = Encoding.UTF8; HttpContext.Current.Response.Write(responseContent); HttpContext.Current.Response.End(); }

asp.net微信开发(消息应答)

asp.net微信开发(消息应答)

精彩专题分享:ASP.NET微信开发教程汇总,欢迎大家学习。

以上就是关于asp.net微信开发的第二篇,针对消息应答进行学习,之后会有更新更多关于asp.net微信开发的文章,希望大家持续关注。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjwjdf.html