


WeChat public account development tutorial Part 9 - Sending and receiving QQ emoticons_PHP tutorial
I think everyone will be familiar with QQ emoticons. Each small avatar greatly enriches the fun of chatting, making chatting no longer a simple text narrative, but can also be accompanied by characters expressing happiness, anger, sadness, joy, etc. Small pictures of mood. The focus of this article is how to use QQ emoticons on the WeChat public platform, that is, in the WeChat public account development mode, how to send QQ emoticons to users, and how to identify that the users are sending QQ emoticons.
QQ emoticon code list
The first thing that needs to be made clear is that although QQ emoticons are presented as dynamic emoticon pictures, they are text messages in the messaging interface of the WeChat public platform; that is to say, when a user sends a QQ emoticon to a public account, The value of the message type MsgType received by the public account background program is text. As long as the above point can be understood, the following work can be carried out easily.
For QQ emoticons, what is sent is a text message, but an emoticon picture is displayed, so each QQ emoticon picture must have a corresponding emoticon code. Below is a comparison table of QQ emoticon codes used in WeChat public accounts:
A total of 105 QQ emoticons are listed above. Each emoticon has its corresponding text code and symbol code (perhaps these two names are not appropriate). As for how these two codes came from And how to use it will be discussed shortly below.
Users send QQ emoticons to public accounts
How to send QQ emoticons when using a public account on WeChat? I think few people don’t know how to do this. There is a smiley face picture button next to the input box. Clicking it will pop up the expression selection interface. The selectable expressions are "QQ emoticons", "symbol emoticons" and "animated emoticons". When we click to select a QQ emoticon, we find that the text code of the emoticon will be displayed in the input box, which is enclosed by a pair of square brackets, as shown in the following figure:
In fact, when we are familiar with the text codes for using QQ emoticons, we can also directly enter the emoticon code in the input box without popping up the emoticon selection box. As shown below:
As can be seen from the picture above, entering the three codes "[呲ya]", "/呲ya" and "/::D" in the input box have the same effect, they all send QQ emoticons of 呲ya . At this time, if you go back and look at the QQ emoticon code comparison table at the beginning of the article, you will understand what is going on.
Public accounts send QQ emoticons to users
Just like users sending QQ emoticons to public accounts, in development mode, public accounts can also use the same emoticon code (text code or symbol code) to reply to users with QQ emoticons. The code snippet is as follows:
// 文本消息 if (msgType.equals(MessageUtil.REQ_MESSAGE_TYPE_TEXT)) { // 回复文本消息 TextMessage textMessage = new TextMessage(); textMessage.setToUserName(fromUserName); textMessage.setFromUserName(toUserName); textMessage.setCreateTime(new Date().getTime()); textMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_TEXT); textMessage.setFuncFlag(0); textMessage.setContent("[难过] /难过 /::("); // 文本消息对象转换成xml字符串 respMessage = MessageUtil.textMessageToXml(textMessage); }
Public accounts identify QQ emoticons sent by users
After mastering how to send QQ emoticons, let’s take a look at how public accounts can identify that users are sending QQ emoticons. What does this mean? When a user sends a QQ emoticon to a public account, what value will be received in the background program, and how do we know that this value is a QQ emoticon.
In fact, as long as you do a simple test, for example: output the received text message to the log (you can use log4j or System.out.print), it is not difficult to find: send a QQ emoticon to the public account, in the background What is received in the program is the symbol code of QQ emoticons.
The following is a method I simply encapsulated, implemented through regular expressions, to determine whether the user sends a single QQ emoticon.
/** * 判断是否是QQ表情 * * @param content * @return */ public static boolean isQqFace(String content) { boolean result = false; // 判断QQ表情的正则表达式 String qqfaceRegex = "/::\\)|/::~|/::B|/::\\||/:8-\\)|/::<|/::$|/::X|/::Z|/::'\\(|/::-\\||/::@|/::P|/::D|/::O|/::\\(|/::\\+|/:--b|/::Q|/::T|/:,@P|/:,@-D|/::d|/:,@o|/::g|/:\\|-\\)|/::!|/::L|/::>|/::,@|/:,@f|/::-S|/:\\?|/:,@x|/:,@@|/::8|/:,@!|/:!!!|/:xx|/:bye|/:wipe|/:dig|/:handclap|/:&-\\(|/:B-\\)|/:<@|/:@>|/::-O|/:>-\\||/:P-\\(|/::'\\||/:X-\\)|/::\\*|/:@x|/:8\\*|/:pd|/:<W>|/:beer|/:basketb|/:oo|/:coffee|/:eat|/:pig|/:rose|/:fade|/:showlove|/:heart|/:break|/:cake|/:li|/:bome|/:kn|/:footb|/:ladybug|/:shit|/:moon|/:sun|/:gift|/:hug|/:strong|/:weak|/:share|/:v|/:@\\)|/:jj|/:@@|/:bad|/:lvu|/:no|/:ok|/:love|/:<L>|/:jump|/:shake|/:<O>|/:circle|/:kotow|/:turn|/:skip|/:oY|/:#-0|/:hiphot|/:kiss|/:<&|/:&>"; Pattern p = Pattern.compile(qqfaceRegex); Matcher m = p.matcher(content); if (m.matches()) { result = true; } return result; }
// 文本消息 if (msgType.equals(MessageUtil.REQ_MESSAGE_TYPE_TEXT)) { // 文本消息内容 String content = requestMap.get("Content"); // 判断用户发送的是否是单个QQ表情 if(XiaoqUtil.isQqFace(content)) { // 回复文本消息 TextMessage textMessage = new TextMessage(); textMessage.setToUserName(fromUserName); textMessage.setFromUserName(toUserName); textMessage.setCreateTime(new Date().getTime()); textMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_TEXT); textMessage.setFuncFlag(0); // 用户发什么QQ表情,就返回什么QQ表情 textMessage.setContent(content); // 将文本消息对象转换成xml字符串 respMessage = MessageUtil.textMessageToXml(textMessage); } }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to master Bootstrap customization and component usage includes: 1. Use CSS variables and Sass preprocessor for style customization; 2. Deeply understand and modify component structure and behavior. Through these methods, a unique user interface can be created to improve the responsiveness and user experience of the website.

H5. The main difference between mini programs and APP is: technical architecture: H5 is based on web technology, and mini programs and APP are independent applications. Experience and functions: H5 is light and easy to use, with limited functions; mini programs are lightweight and have good interactiveness; APPs are powerful and have smooth experience. Compatibility: H5 is cross-platform compatible, applets and APPs are restricted by the platform. Development cost: H5 has low development cost, medium mini programs, and highest APP. Applicable scenarios: H5 is suitable for information display, applets are suitable for lightweight applications, and APPs are suitable for complex functions.

This article provides a detailed guide to safe download of Ouyi OKX App in China. Due to restrictions on domestic app stores, users are advised to download the App through the official website of Ouyi OKX, or use the QR code provided by the official website to scan and download. During the download process, be sure to verify the official website address, check the application permissions, perform a security scan after installation, and enable two-factor verification. During use, please abide by local laws and regulations, use a safe network environment, protect account security, be vigilant against fraud, and invest rationally. This article is for reference only and does not constitute investment advice. Digital asset transactions are at your own risk.

Compatibility issues and troubleshooting methods for company security software and application. Many companies will install security software in order to ensure intranet security. However, security software sometimes...

H5 is more flexible and customizable, but requires skilled technology; mini programs are quick to get started and easy to maintain, but are limited by the WeChat framework.

Discussion on the JS resource caching issue of Enterprise WeChat. When upgrading project functions, some users often encounter situations where they fail to successfully upgrade, especially in the enterprise...

The choice of H5 and applet depends on the requirements. For applications with cross-platform, rapid development and high scalability, choose H5; for applications with native experience, rich functions and platform dependencies, choose applets.

This article provides a brief guide to buying and selling of Binance virtual currency updated in 2025, and explains in detail the operation steps of virtual currency transactions on the Binance platform. The guide covers fiat currency purchase USDT, currency transaction purchase of other currencies (such as BTC), and selling operations, including market trading and limit trading. In addition, the guide also specifically reminds key risks such as payment security and network selection for fiat currency transactions, helping users to conduct Binance transactions safely and efficiently. Through this article, you can quickly master the skills of buying and selling virtual currencies on the Binance platform and reduce transaction risks.
