


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



DeepSeek: A powerful AI image generation tool! DeepSeek itself is not an image generation tool, but its powerful core technology provides underlying support for many AI painting tools. Want to know how to use DeepSeek to generate images indirectly? Please continue reading! Generate images with DeepSeek-based AI tools: The following steps will guide you to use these tools: Launch the AI Painting Tool: Search and open a DeepSeek-based AI Painting Tool (for example, search "Simple AI"). Select the drawing mode: select "AI Drawing" or similar function, and select the image type according to your needs, such as "Anime Avatar", "Landscape"

Gate.io, a leading cryptocurrency trading platform founded in 2013, provides Chinese users with a complete official Chinese website. The website provides a wide range of services, including spot trading, futures trading and lending, and provides special features such as Chinese interface, rich resources and community support.

The OKX trading platform offers a variety of rates, including transaction fees, withdrawal fees and financing fees. For spot transactions, transaction fees vary according to transaction volume and VIP level, and adopt the "market maker model", that is, the market charges a lower handling fee for each transaction. In addition, OKX also offers a variety of futures contracts, including currency standard contracts, USDT contracts and delivery contracts, and the fee structure of each contract is also different.

Gateio Exchange app download channels for old versions, covering official, third-party application markets, forum communities and other channels. It also provides download precautions to help you easily obtain old versions and solve the problems of discomfort in using new versions or device compatibility.

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.

Gate.io (Sesame Open Door) is the world's leading cryptocurrency trading platform. This article provides a complete tutorial on spot trading of Gate.io. The tutorial covers steps such as account registration and login, KYC certification, fiat currency and digital currency recharge, trading pair selection, limit/market transaction orders, and orders and transaction records viewing, helping you quickly get started on the Gate.io platform for cryptocurrency trading. Whether a beginner or a veteran, you can benefit from this tutorial and easily master the Gate.io trading skills.

Learn to easily copy Xiaohongshu copywriting! This tutorial teaches you step by step how to quickly copy Xiaohongshu video copy, saying goodbye to tedious steps. Open the Xiaohongshu APP, find the video you like, and click on the [Copywriting] area below the video. Long press the copy text and select the [Extract Text] function from the pop-up options. The system will automatically extract the text, click the [Copy] button in the lower left corner. Open WeChat or other applications, such as Moments, long press the input box, and select [Paste]. Click Send to complete the copy. It's that simple!

Huobi to Binance Transfer Guide: Safe and conveniently transfer your crypto assets Many investors use Huobi and Binance at the same time. This article will guide you how to safely transfer crypto assets on Huobi (HTX), such as TRUMP and USDT, to the Binance platform. Binance is popular for its high security, rich currency and trading pairs, and world-leading trading volume. Binance Exchange’s advantages: the world’s number one trading volume, accounting for 50% of the global market; transparent reserve assets are mainly mainstream stablecoins such as Bitcoin, Ethereum and USDT; it has effectively avoided the potential risks of the US SEC and is one of the most stable and reliable exchanges at present. This tutorial will take TRUMP and USDT as examples
