The previous article has successfully responded to the event of concern and also realized the sending of text messages. This article starts the processing of graphic messages. The most commonly used message type in WeChat is graphic messages, because it combines pictures and text and can best express information. The interface definition of graphic messages in WeChat is as follows:
<xml> <tousername></tousername> <fromusername></fromusername> <createtime>12345678</createtime> <msgtype></msgtype> <articlecount>2</articlecount> <articles> <item> <title></title> <description></description> <picurl></picurl> <url></url> </item> <item> <title></title> <description></description> <picurl></picurl> <url></url> </item> </articles> </xml>
Add text definition:
Many people see it for the first time You may find this document difficult to understand because the writing is not very intuitive. You will understand after a few more glances. Developers, users, time, etc. are the same as text messages and other messages. The only difference is that The articles node in the graphic message is a node with multiple records. It is at the same level as other nodes, and the specific article is equivalent to a child. This is very intuitive after reading the graphic message model defined in the previous article. I regard the article as a separate The list is used as an attribute in the graphic message model.
Let’s simulate a few pieces of data here
SNews mN = new SNews(); mN.FromUserName = ReadXml.ReadModel("ToUserName", model); mN.ToUserName = ReadXml.ReadModel("FromUserName", model); mN.CreateTime = long.Parse(ReadXml.ReadModel("CreateTime", model)); mN.MsgType = "news"; // 以下为文章内容, 实际使用时,此处应该是一个跟数据库交互的方法,查询出文章 //文章条数, 文章内容等 都应该由数据库查询出来的数据决定 这里测试,就模拟几条 mN.ArticleCount =5; List<articlesmodel> listNews = new List<articlesmodel>(); for (int i = 0; i <p><br></p> <p>demo is the input? Or? Or help Reply text menu, enter other characters to reply with image and text </p> <p> Effect: </p> <p><img src="https://img.php.cn//upload/image/383/395/162/1487830560310636.jpg" title="asp.net develops WeChat public platform (5) WeChat graphic messages" alt="asp.net develops WeChat public platform (5) WeChat graphic messages" style="max-width:90%" style="max-width:90%"></p> <p><img src="https://img.php.cn//upload/image/499/721/917/1487830571507114.jpg" title="asp.net develops WeChat public platform (5) WeChat graphic messages" alt="asp.net develops WeChat public platform (5) WeChat graphic messages" style="max-width:90%" style="max-width:90%"></p> <p>The image and text message exceeds When there is 1 article, the first article will be displayed in a large image by default, and only the title will be displayed for each article. When there is only one article, an introduction will be displayed, as shown in the figure: </p> <p><img src="https://img.php.cn//upload/image/853/782/961/1487830588572998.jpg" title="asp.net develops WeChat public platform (5) WeChat graphic messages" alt="asp.net develops WeChat public platform (5) WeChat graphic messages" style="max-width:90%" style="max-width:90%"></p> <p></p> <p> No matter how many articles there are, clicking on each article will open the assigned article link. At this time, it is equivalent to opening a browser to visit your web page. You can design this page in any way. Due to the size of the mobile phone No, it’s best to consider screen adaptation when designing this page and make it a responsive layout</p> <p> </p> <p> Okay, that’s all the graphic and text messages. So far, all the basics of WeChat The content is basically completed. In Part 7, I will release the complete source code of the demo version. I promise to take it back and throw it on the server to specify a domain name. Then go to the WeChat official to fill it out and you will see the effect immediately... </p> <p><br></p> <p>For more asp.net development WeChat public platform (5) WeChat graphic messages related articles, please pay attention to the PHP Chinese website! </p> <p><br><br></p></articlesmodel></articlesmodel>