In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how C # realizes the response of text message and picture message". The content is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "how to achieve text message and picture message response".
Send response messages to mobile phone users, it can be divided into many ways, such as reply text message, reply picture message, reply voice message, reply video message, reply music message, reply picture message and so on, as shown below.
Among the three methods, picture, video and voice, you need to activate Wechat authentication before you can send media information stored on the Wechat server to users. Generally, there is no official account or service number for authentication. You can't send these kinds of content.
1. Entity information relationship and definition
In my last Wechat development essay, I showed the application entity classes that receive messages and reply messages. These entity classes are encapsulated at the application level according to my needs and development needs. The message relationship of the reply is as follows.
The entity class definition of the message base class BaseMessage is shown below, which constructs an integer value for the date and has some regular properties, as well as an important ToXML method for passing these XML data to the method.
/ basic message content / / [XmlRoot (ElementName = "xml")] public class BaseMessage {/ initialize some content, such as shaping the creation time, / public BaseMessage () {this.CreateTime = DateTime.Now.DateTimeToInt () } / developer Wechat / public string ToUserName {get; set;} / sender account (an OpenID) / public string FromUserName {get; set } / message creation time (integer) / public int CreateTime {get; set;} / public string MsgType {get; set;} public virtual string ToXml () {this.CreateTime = DateTime.Now.DateTimeToInt () / / renew return MyXmlHelper.ObjectToXml (this);}}
The reply text message entity class code is shown below. We can see that it inherits a lot of common entity attributes and has a general method of ToXml, which we can use when we need to convert it to the XML of the response.
/ / reply text message / [System.Xml.Serialization.XmlRoot (ElementName = "xml")] public class ResponseText: BaseMessage {public ResponseText () {this.MsgType = ResponseMsgType.Text.ToString () .ToLower ();} public ResponseText (BaseMessage info): this () {this.FromUserName = info.ToUserName This.ToUserName = info.FromUserName;} / content / public string Content {get; set;}}
And the picture-text message object class ResponseNews, which contains more information definitions
/ / reply to the Teletext message / [System.Xml.Serialization.XmlRoot (ElementName = "xml")] public class ResponseNews: BaseMessage {public ResponseNews () {this.MsgType = ResponseMsgType.News.ToString () .ToLower (); this.Articles = new List () } public ResponseNews (BaseMessage info): this () {this.FromUserName = info.ToUserName; this.ToUserName = info.FromUserName } / the number of picture and text messages is limited to 10 messages / public int ArticleCount {get {return this.Articles.Count;} set { / / add this step to XML content}} / the list of graphics and text. / / multiple picture and text messages. By default, the first item is a large image. Note that if the number of pictures and texts exceeds 10, there will be no response / [System.Xml.Serialization.XmlArrayItem ("item")] public List Articles {get; set;}}
The object in the list of pictures and texts, which is also an entity type, contains some links to pictures and texts, titles and other information, which will not be repeated.
2. Reply processing of message
For example, for text messages, we can handle them in the following ways.
ResponseText response = new ResponseText (info); response.Content = "Sorry, this feature is not enabled yet." ; result = response.ToXml ()
For picture and text messages, we may need to enter more messages to return better results.
Pay attention to the news of the picture and text, the size of the picture had better be in accordance with the official standard, otherwise it does not look good on the phone, the official standard seems to be a width and height of (360200) pixels
/ subscribe or display company information / private string ShowCompanyInfo (BaseMessage info) {string result = ""; / / Teletext information (single text message) ResponseNews response = new ResponseNews (info) used on Wechat platform; ArticleEntity entity = new ArticleEntity () Entity.Title = "Guangzhou Aiqidi Software Technology Co., Ltd."; entity.Description = "Welcome to Guangzhou Aiqidi Software, a professional provider of information software and software development framework, we are determined to provide customers with the best software and services. \ r\ n "; entity.Description + =" We are a highly innovative software technology company engaged in researching, developing and selling the most reliable, safe and easy-to-use technology products and quality professional services to help global customers and partners succeed. \ r\ n. (1000 words are omitted here, ) "; entity.PicUrl =" http://www.php.cn/"; entity.Url = "http://www.php.cn/"; response.Articles.Add (entity); result = response.ToXml (); return result;}
Let's take a look at our company's Wechat portal menu. Doesn't it look cool?
For these two kinds of (text message, picture and text message) is the most used, many Wechat portals, mainly use these two ways to respond. Of course, we can also carry out different processing according to the various messages submitted by the customer's mobile phone. I introduced the types of request messages in my essay in the previous article, as shown below.
The above is all the content of the article "how to realize the response of text message and picture message in C#". 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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.