亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home Backend Development PHP Tutorial WeChat Public Account Development Tutorial Part 13 - Complete Guide to Graphic and Text Messages_PHP Tutorial

WeChat Public Account Development Tutorial Part 13 - Complete Guide to Graphic and Text Messages_PHP Tutorial

Jul 20, 2016 am 11:12 AM
Complete strategy content Graphics and text develop WeChat complain Tutorial have information

Introduction and summary

Several readers have complained that "Liu Feng only used text messages as examples, never mentioned graphic messages, and did not know how to use graphic messages." Well, I was wrong. I originally thought that the basic API After encapsulation is completed, the framework is set up, and an example of using text messages is given, everyone can imitate a cat and draw a tiger. Perhaps it is because my painting skills are so poor that the cat I drew does not look like a cat in the first place...

This article mainly introduces the use of graphic messages in WeChat public account development, as well as several forms of graphic messages. The title is "Comprehensive Guide to Graphic and Text Messages". This is definitely not a clickbait. I want to take this opportunity to clear away all the questions, doubts and obstacles related to graphic and text messages.

Explanation of the main parameters of graphic messages

Through WeChat’s official message interface guide, you can see the parameter introduction of graphic messages, as shown in the figure below:

You can understand from the picture:

1) The number of graphic and text messages is limited to 10, which is the value of ArticleCount in the picture (the number of graphic and text messages is limited to 10);

2) For multi-image and text messages, the image of the first image and text is displayed as a large image, and the images of other images and texts are displayed as small images;

3) The recommended image size for the first graphic and text is 640*320, and the recommended image size for other graphic and text is 80*80;

Okay, after understanding these, combined with the encapsulation of messages and message processing tools mentioned in the fourth article, it is not difficult to reply graphic messages to users.

Multiple expressions of graphic messages

The following directly demonstrates the usage of the five main forms of graphic messages through code. The source code is as follows:

[java]?view plaincopy ?
  1. package?org.liufeng.course.service;??
  2. ??
  3. import?java.util.ArrayList;??
  4. import?java.util.Date;??
  5. import?java.util.List;??
  6. import?java.util.Map;??
  7. ??
  8. import?javax.servlet.http.HttpServletRequest;??
  9. ??
  10. import?org.liufeng.course.message.resp.Article;??
  11. import?org.liufeng.course.message.resp.NewsMessage;??
  12. import?org.liufeng.course.message.resp.TextMessage;??
  13. import?org.liufeng.course.util.MessageUtil;??
  14. ??
  15. /**?
  16. * Core service class
  17. *
  18. * @author liufeng
  19. * @date 2013-07-25
  20. */
  21. public class CoreService {?
  22. /**
  23. * Processing requests from WeChat
  24. ?????*??
  25. ?????*?@param?request?
  26. ?????*?@return?
  27. ?????*/??
  28. ????public?static?String?processRequest(HttpServletRequest?request)?{??
  29. ????????String?respMessage?=?null;??
  30. ????????try?{??
  31. ?//xml request parsing?
  32. Map requestMap = MessageUtil.parseXml(request);
  33. ?//Sender account (open_id)
  34. String fromUserName = requestMap.get("FromUserName");
  35. ?//Public Account?
  36. String toUserName = requestMap.get("ToUserName");
  37. ???????????????????????????????????????????????????????????????????????????????????????????? String msgType = requestMap.get("MsgType");
  38. //Default reply to this text message
  39. TextMessage textMessage = new TextMessage();
  40. textMessage.setToUserName(fromUserName);
  41. textMessage.setFromUserName(toUserName);
  42. textMessage.setCreateTime(new Date().getTime());
  43. textMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_TEXT);
  44. textMessage.setFuncFlag(0);
  45. /// Because the HREF attribute value must be caused by dual quotes, this is conflict with the double quotes of the string itself, so we must turn to
  46. textMessage.setContent("Welcome toLiu Feng’s blog!" );
  47. ?//Convert the text message object into an xml string
  48. respMessage = MessageUtil.textMessageToXml(textMessage);
  49. ?//Text Message?
  50. if (msgType.equals(MessageUtil.REQ_MESSAGE_TYPE_TEXT)) {
  51. ?//Receive text message content sent by the user
  52. String content = requestMap.get("Content");
  53. ?//Create graphic message
  54. ????????????????NewsMessage?newsMessage?=?new?NewsMessage();??
  55. ????????????????newsMessage.setToUserName(fromUserName);??
  56. ????????????????newsMessage.setFromUserName(toUserName);??
  57. ????????????????newsMessage.setCreateTime(new?Date().getTime());??
  58. ????????????????newsMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_NEWS);??
  59. ????????????????newsMessage.setFuncFlag(0);??
  60. ??
  61. List
    articleList = new ArrayList
    ();
  62. ?//Single picture and text message
  63. ?if ("1".equals(content)) {
  64. Article article = new Article();
  65. article.setTitle("WeChat Public Account Development Tutorial Java Edition");
  66. article.setDescription("Liu Feng, born in the 1980s, has 4 months of experience in WeChat public account development.In order to help beginners get started, we have launched this series of tutorials. We also hope to take this opportunity to meet more colleagues!");
  67. article.setPicUrl("http://0.xiaoqrobot.duapp.com/images/avatar_liufeng.jpg");
  68. article.setUrl("http://blog.csdn.net/lyq8479");
  69. articleList.add(article);
  70. ?//Set the number of graphic messages
  71. newsMessage.setArticleCount(articleList.size());
  72. ?????????????????????????????????????????????????????????????????????????????????????????? newsMessage.setArticles(articleList);
  73. ???????????????????????????????????????????????????????? respMessage = MessageUtil.newsMessageToXml(newsMessage);
  74. }
  75. ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?else
  76. if ("2".equals(content) ) { Article article = new Article();
  77. article.setTitle("WeChat Public Account Development Tutorial Java Edition");
  78. ?// QQ emoticons and emoticons can be used in graphic messages
  79. article.setDescription("Liu Feng, born in the 80s," + emoji(0x1F6B9)
  80. + ", WeChat public account development experience is 4 months. To help beginners from getting started, this series of serialization tutorials are launched. 12 articles, including interface configuration, message encapsulation, framework construction, QQ emoticon sending, symbol emoticon sending, etc. nn also plans to introduce the development explanation of some practical functions in the future, such as weather forecast, surrounding search, chat function, etc.");??
  81. ????????????????????//?將圖片置為空??
  82. ????????????????????article.setPicUrl("");??
  83. ????????????????????article.setUrl("http://blog.csdn.net/lyq8479");??
  84. ????????????????????articleList.add(article);??
  85. ????????????????????newsMessage.setArticleCount(articleList.size());??
  86. ????????????????????newsMessage.setArticles(articleList);??
  87. ????????????????????respMessage?=?MessageUtil.newsMessageToXml(newsMessage);??
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
Copy comics (official website entrance)_Copy comics (nba) genuine online reading portal Copy comics (official website entrance)_Copy comics (nba) genuine online reading portal Jun 05, 2025 pm 04:12 PM

Copying comics is undoubtedly a treasure that cannot be missed. Here you can find basketball comics in various styles, from passionate and inspiring competitive stories to relaxed and humorous daily comedy. Whether you want to relive the classics or discover new works, copying comics can meet your needs. Through the authentic online reading portal provided by copy comics, you will bid farewell to the trouble of pirated resources, enjoy a high-definition and smooth reading experience, and can support your favorite comic authors and contribute to the development of authentic comics.

Top 10 AI writing software rankings Recommended Which AI writing software is free Top 10 AI writing software rankings Recommended Which AI writing software is free Jun 04, 2025 pm 03:27 PM

Combining the latest industry trends and multi-dimensional evaluation data in 2025, the following are the top ten comprehensive AI writing software recommendations, covering mainstream scenarios such as general creation, academic research, and commercial marketing, while taking into account Chinese optimization and localization services:

Watch the official page of NIS comics online for free comics. The free entry website of NIS comics login page Watch the official page of NIS comics online for free comics. The free entry website of NIS comics login page Jun 12, 2025 pm 08:18 PM

Nice Comics, an immersive reading experience platform dedicated to creating for comic lovers, brings together a large number of high-quality comic resources at home and abroad. It is not only a comic reading platform, but also a community that connects comic artists and readers and shares comic culture. Through simple and intuitive interface design and powerful search functions, NES Comics allows you to easily find your favorite works and enjoy a smooth and comfortable reading experience. Say goodbye to the long waiting and tedious operations, enter the world of Nice comics immediately and start your comic journey!

Frog Man Online Viewing Entrance Man Frog Man (Web Page Entrance) Watch Online Frog Man Online Viewing Entrance Man Frog Man (Web Page Entrance) Watch Online Jun 12, 2025 pm 08:06 PM

Frogman Comics has become the first choice for many comic lovers with its rich and diverse comic resources and convenient and smooth online reading experience. It is like a vibrant pond, with fresh and interesting stories constantly emerging, waiting for you to discover and explore. Frog Man comics cover a variety of subjects, from passionate adventures to sweet love, from fantasy and science fiction to suspense reasoning, no matter which genre you like, you can find your favorite works here. Its simple and intuitive interface design allows you to easily get started, quickly find the comics you want to read, and immerse yourself in the exciting comic world.

Baozi Comics (Entrance)_ Baozi Comics (New Entrance) 2025 Baozi Comics (Entrance)_ Baozi Comics (New Entrance) 2025 Jun 05, 2025 pm 04:18 PM

Here, you can enjoy the vast ocean of comics and explore works of various themes and styles, from passionate young man comics to delicate and moving girl comics, from suspenseful and brain-burning mystery comics to relaxed and funny daily comics, there is everything, and there is always one that can touch your heartstrings. We not only have a large amount of genuine comic resources, but also constantly introduce and update the latest works to ensure that you can read your favorite comics as soon as possible.

How to download Huobi on Android phones? Huobi download tutorial (step-by-step tutorial) How to download Huobi on Android phones? Huobi download tutorial (step-by-step tutorial) Jun 12, 2025 pm 10:12 PM

Android mobile phone users can download and install Huobi/Huobi App through the following steps: 1. Ensure the network is stable and the storage space is sufficient; 2. Download the App through Huobi/Huobi official website, use the browser to access the official website and click the download link or scan the QR code, or search and download through third-party application stores such as AppTreasure and Huawei App Market, and you can also obtain the installation package through friends' sharing; 3. Find the downloaded .apk file, enable the "Unknown Source App" installation permission, follow the prompts to complete the installation, etc.

Can I use WeChat on two phones at the same time? Can I use WeChat on two phones at the same time? Jul 11, 2025 am 03:28 AM

Yes, but there are restrictions. ① You can log in to the same account on both iPhone and Android phones, but logging in to the latest device will cause the earliest session to be offline; ② You can log in at the same time on the mobile phone and the computer desktop, but the functions are not synchronized; ③ Although using third-party tools or dual-app functions can enable logging in between two mobile phones, it is unofficially supported and may violate regulations; ④ Alternative solutions include using web version/desktop version to match the main phone, or transferring chat records through cloud backup and file tools. Some Android machines can also use "dual applications" to run two account instances.

Yiou Exchange Download and Installation Pack Yiou Android Download and Installation Pack Yiou Exchange Download and Installation Pack Yiou Android Download and Installation Pack Jun 12, 2025 pm 10:09 PM

The steps for downloading and installing the Yiou Exchange (OKX) Android client are as follows: 1. Download the official genuine installation package through the official website www.okx.com or the official QR code; 2. Find the downloaded .apk file in the mobile phone file manager and enable the "Unknown Source" installation permission; 3. Click the installation package to install, and after the installation is completed, open the APP and register or log in to the account; 4. Set up complex passwords, enable secondary verification, regularly change passwords, properly keep private keys and mnemonics, and beware of phishing websites to ensure account security.

See all articles