国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
1. Entity information relationships and definitions
2. Message reply processing
Home WeChat Applet WeChat Development C# Development of WeChat Portal and Application (3)--Response to text messages and graphic messages

C# Development of WeChat Portal and Application (3)--Response to text messages and graphic messages

Feb 16, 2017 pm 04:32 PM

WeChat applications are in full swing, and many companies hope to get on the information express. This is a business opportunity and a technical direction. Therefore, it has become one of the planned arrangements to study and learn about the development of WeChat when you have time. . This series of articles hopes to comprehensively introduce the relevant development process and related experience summary of WeChat from a step-by-step perspective, hoping to give everyone an understanding of the relevant development process.

In the first two articles, "C# Developing WeChat Portal and Application (1)--Starting to Use WeChat Interface" and "C# Developing WeChat Portal and Application (2)--Processing and Responding to WeChat Messages" In it, I roughly introduce the framework construction of my WeChat application. This essay continues to introduce this topic and introduces the process of text response and graphic response in message response.

We know that sending response messages to mobile phone users can be divided into many ways, such as replying to text messages, replying to picture messages, replying to voice messages, replying to video messages, replying to music messages, replying to picture and text messages, etc. ,As follows.

C#開發(fā)微信門戶及應用(3)--文本消息和圖文消息的應答

Among the three methods, pictures, videos, and voices, you need to activate WeChat authentication before you can send media information stored on the WeChat server to users. Generally, the public does not have authentication. Accounts or service accounts cannot send these types of content.

1. Entity information relationships and definitions

In the last essay on WeChat development, I showed the application entity classes for receiving messages and replying to messages. These entity classes are what I need. , based on development needs, they are encapsulated at the application level. For example, the reply message relationship is as follows.

C#開發(fā)微信門戶及應用(3)--文本消息和圖文消息的應答

The entity class definition of the message base class BaseMessage is as follows. It constructs an integer value for the date and has some general attributes, and there is also an important The ToXML method is used to pass these XML data to the method.

????///?<summary>
????///?基礎消息內(nèi)容????///?</summary>
????[XmlRoot(ElementName?=?"xml")]????public?class?BaseMessage
????{????????///?<summary>
????????///?初始化一些內(nèi)容,如創(chuàng)建時間為整形,????????///?</summary>
????????public?BaseMessage()
????????{????????????this.CreateTime?=?DateTime.Now.DateTimeToInt();
????????}????????///?<summary>
????????///?開發(fā)者微信號????????///?</summary>
????????public?string?ToUserName?{?get;?set;?}????????///?<summary>
????????///?發(fā)送方帳號(一個OpenID)????????///?</summary>
????????public?string?FromUserName?{?get;?set;?}????????///?<summary>
????????///?消息創(chuàng)建時間?(整型)????????///?</summary>
????????public?int?CreateTime?{?get;?set;?}????????///?<summary>
????????///?消息類型????????///?</summary>
????????public?string?MsgType?{?get;?set;?}????????public?virtual?string?ToXml()
????????{????????????this.CreateTime?=?DateTime.Now.DateTimeToInt();//重新更新
????????????return?MyXmlHelper.ObjectToXml(this);
????????}

????}

The text message entity class code of the reply is as follows. We can see that it inherits many common entity attributes and also has There is a general method of ToXml. When we need to convert it into response XML, we can just use this method.

????///?<summary>
????///?回復文本消息????///?</summary>
????[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;
????????}????????///?<summary>
????????///?內(nèi)容????????///?</summary>????????
????????public?string?Content??{?get;?set;?}
????}

The graphic message object class ResponseNews contains more information definitions

????///?<summary>
????///?回復圖文消息????///?</summary>
????[System.Xml.Serialization.XmlRoot(ElementName?=?"xml")]????public?class?ResponseNews?:?BaseMessage
????{????????public?ResponseNews()
????????{????????????this.MsgType?=?ResponseMsgType.News.ToString().ToLower();????????????this.Articles?=?new?List<ArticleEntity>();
????????}????????public?ResponseNews(BaseMessage?info)?:?this()
????????{????????????this.FromUserName?=?info.ToUserName;????????????this.ToUserName?=?info.FromUserName;
????????}????????///?<summary>
????????///?圖文消息個數(shù),限制為10條以內(nèi)????????///?</summary>
????????public?int?ArticleCount
????????{????????????get
????????????{????????????????return?this.Articles.Count;
????????????}????????????set
????????????{
????????????????;//增加這個步驟才出來XML內(nèi)容????????????}
????????}????????///?<summary>
????????///?圖文列表。????????///?多條圖文消息信息,默認第一個item為大圖,注意,如果圖文數(shù)超過10,則將會無響應????????///?</summary>
????????[System.Xml.Serialization.XmlArrayItem("item")]????????public?List<ArticleEntity>?Articles?{?get;?set;?}

????}

The objects in the image and text list collection are also an entity type and contain some image and text links, titles and other information, which will not be described in detail.

2. Message reply processing

For text messages, we can process them in the following ways.

????????????????ResponseText?response?=?new?ResponseText(info);
????????????????response.Content?=?"抱歉,此功能暫未開通。";
????????????????result?=?response.ToXml();

For graphic and text messages, we may need to enter more messages to return better results.

Pay attention to the picture and text information. It is best to follow the official standard for the size of the picture, otherwise it will not look good on the mobile phone. The official standard seems to be (360,200) pixels in width and height

????????///?<summary>
????????///?訂閱或者顯示公司信息????????///?</summary>
????????///?<param name="info"></param>
????????///?<returns></returns>
????????private?string?ShowCompanyInfo(BaseMessage?info)
????????{????????????string?result?=?"";????????????//使用在微信平臺上的圖文信息(單圖文信息)
????????????ResponseNews?response?=?new?ResponseNews(info);
????????????ArticleEntity?entity?=?new?ArticleEntity();
????????????entity.Title?=?"廣州愛奇迪軟件科技有限公司";
????????????entity.Description?=?"歡迎關注廣州愛奇迪軟件--專業(yè)的單位信息化軟件和軟件開發(fā)框架提供商,我們立志于為客戶提供最好的軟件及服務。\r\n";
????????????entity.Description?+=?"我們是一家極富創(chuàng)新性的軟件科技公司,從事研究、開發(fā)并銷售最可靠的、安全易用的技術產(chǎn)品及優(yōu)質(zhì)專業(yè)的服務,幫助全球客戶和合作伙伴取得成功。\r\n......(此處省略1000字,哈哈)";
????????????entity.PicUrl?=?"http://m.miracleart.cn/";
????????????entity.Url?=?"http://m.miracleart.cn/";

????????????response.Articles.Add(entity);
????????????result?=?response.ToXml();????????????return?result;
????????}

Let’s take a look at my company’s WeChat portal menu, doesn’t it look cool?

C#開發(fā)微信門戶及應用(3)--文本消息和圖文消息的應答

These two types (text messages and graphic messages) are the most used. Many WeChat portals mainly use these two methods to respond. Of course, we can also perform different processing based on various messages submitted by customers’ mobile phones. I introduced the types of request messages in the previous essay, as shown below.

C#開發(fā)微信門戶及應用(3)--文本消息和圖文消息的應答

#If you need to pay attention to understand the overall effect, you can use WeChat to directly scan the QR code.

C#開發(fā)微信門戶及應用(3)--文本消息和圖文消息的應答

More C# development of WeChat portals and applications (3)--Response to text messages and graphic messages For related articles, please pay attention to the PHP Chinese website!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276