Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use .net code to send text messages in the development of Wechat public platform

Shulou Source: shulou.com Published: 2022-06-03 12:52:28 11月15日 Update

This article mainly shows you "how to use .net code to send text messages in the development of Wechat public platform". The content is simple and clear. I hope it can help you solve your doubts. Now let me lead you to study and learn this article "how to use .net code to send text messages in the development of Wechat public platform".

The details are as follows

First create a Wechat message class.

Class wxmessage {public string FromUserName {get; set;} public string ToUserName {get; set;} public string MsgType {get; set;} public string EventName {get; set;} public string Content {get; set;} public string EventKey {get; set;}}

The backend code is as follows:

Protected void Page_Load (object sender, EventArgs e) {wxmessage wx = GetWxMessage (); string res = ""; if (! string.IsNullOrEmpty (wx.EventName) & & wx.EventName.Trim () = "subscribe") {/ / the welcome word string content = "; content =" /: rose Welcome Beijing Yongjie Youxin Technology Co., Ltd. /: rose\ nreply "Hello" directly; res = sendTextMessage (wx, content) } else {if (wx.MsgType = = "text" & & wx.Content = = "Hello") {res = sendTextMessage (wx, "Hello, welcome to the public Wechat platform of Beijing Yongjie Youxin Technology Co., Ltd.");} else {res = sendTextMessage (wx, "Hello, unable to identify the message!");}} Response.Write (res) } private wxmessage GetWxMessage () {wxmessage wx = new wxmessage (); StreamReader str = new StreamReader (Request.InputStream, System.Text.Encoding.UTF8); XmlDocument xml = new XmlDocument (); xml.Load (str); wx.ToUserName = xml.SelectSingleNode ("xml"). SelectSingleNode ("ToUserName"). InnerText; wx.FromUserName = xml.SelectSingleNode ("xml"). SelectSingleNode ("FromUserName"). InnerText; wx.MsgType = xml.SelectSingleNode ("xml"). SelectSingleNode ("MsgType"). InnerText If (wx.MsgType.Trim () = = "text") {wx.Content = xml.SelectSingleNode ("xml"). SelectSingleNode ("Content"). InnerText;} if (wx.MsgType.Trim () = = "event") {wx.EventName = xml.SelectSingleNode ("xml"). SelectSingleNode ("Event"). InnerText;} return wx } / send text messages / content / private string sendTextMessage (wxmessage wx, string content) {string res = string.Format (@ ", wx.FromUserName, wx.ToUserName, DateTime.Now, content); return res } these are all the contents of the article "how to use .net code to send text messages in the development of Wechat public platform". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Message content code platform hello public text development article company limited limited technology Beijing learning help information background text time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Huawei MySQL Shulou Tech Info Shulou Information