Home  >  Article  >  Backend Development  >  WeChat Public Account Development Tutorial Part 12 - Sending Emoticons (Part 2)_PHP Tutorial

WeChat Public Account Development Tutorial Part 12 - Sending Emoticons (Part 2)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-20 11:12:301139browse

Introduction and article summary

The 11th article gives the code list of the Unified version of emoticons (emoji expressions), and introduces how to send emoji expressions in the WeChat public account development mode. It also sells it at the end of the article: "Little Some emoticons used in the q robot cannot be found in the emoticon selection column of WeChat, and they are not found in the emoticon code table (Unified version) given in the previous article. So how are these emoticons sent? ?" The symbolic expressions "couple" and "bus" are shown in the two pictures below.

 

This article mainly introduces the following contents: 1) How to use more emoticons on WeChat (that is, how to send emoji expressions that do not exist in the emoticon selection column of WeChat); 2) Gives a code comparison of the SoftBank version of emoticons Table; 3) Introduce and demonstrate how to send SoftBank version of emoticons. Let everyone completely play with the emoji expressions of WeChat public accounts!

How to use more emoticons on WeChat

Let’s first look at how, as a WeChat user, you can send some emoticons that are not listed in the WeChat emoticon selection column to your friends or WeChat public accounts. For example: What should I do if I want to use the two emoticons "couple" and "bus" used in the Xiaoq robot when chatting with friends on WeChat? Please take a look at the two screenshots below:

 

It can be seen that when we enter the full spelling "qinglv" of "couple" and the full spelling "gonggongqiche" of "bus" in the input box, the corresponding symbols will be automatically displayed in the text prompt list of the input method Expression, how about it, is it easy? There are many more such expressions, such as toilet, toilet, cash machine, etc.

Note: The author used the input method that comes with the iPhone 4S mobile phone system for testing. If you use Android or a third-party input method, that is a different matter.

SoftBank version of Emoji code list

As mentioned in the previous article, there are many versions of emoji, including Unified, DoCoMo, KDDI, Softbank and Google, and different versions use different Unicode codes to represent the same emoticon. This article gives the SoftBank (Japanese SoftBank Group) version of the emoji expression code table (generally called SB Unicode on the Internet, referring to it), as shown in the figure below:

How to send SoftBank version of emoticons to users from public accounts

In the WeChat public account development mode, sending the SoftBank version of emoticons is much simpler than sending the Unified version of emoticons. Simply write the SoftBank Unicode value corresponding to the emoticon in the program code and return it to the user. No need Do any processing.

Below, I give an example of sending the SoftBank version of emoticons. The code is as follows:

package org.liufeng.course.service;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.liufeng.course.message.resp.TextMessage;
import org.liufeng.course.util.MessageUtil;

/**
 * 核心服务类
 * 
 * @author liufeng
 * @date 2013-07-21
 */
public class CoreService {
	/**
	 * 处理微信发来的请求
	 * 
	 * @param request
	 * @return
	 */
	public static String processRequest(HttpServletRequest request) {
		String respMessage = null;
		try {
			// xml请求解析
			Map<String, String> requestMap = MessageUtil.parseXml(request);

			// 发送方帐号(open_id)
			String fromUserName = requestMap.get("FromUserName");
			// 公众帐号
			String toUserName = requestMap.get("ToUserName");

			// 回复文本消息
			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("自行车\ue136 男人\ue138 钱袋\ue12f 情侣\ue428 公共汽车\ue159");
			respMessage = MessageUtil.textMessageToXml(textMessage);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return respMessage;
	}
}

The function of the above code is: no matter what type of message the user sends, it will return a text message containing 5 emoji expressions. If you don’t understand what’s going on with the CoreService class, please check out Part 5 of this series of tutorials, or you just need to look carefully at line 42 of the code to know how to put the SoftBank version of the emoji expression code in the Content of the text message. Finally, let’s take a look at the screenshot of the running effect:

Note: Each emoticon has its corresponding Unified unicode and Softbank unicode code. It does not mean that emoji expressions such as "couple" and "bus" that cannot be found in WeChat's emoticon column can only be By sending it through the method in this article, as long as you get the corresponding Unified unicode code, you can also use the method described in the previous article to send this type of emoticon.

Okay, this is the end of the explanation about sending emoticons to users from WeChat public accounts. I believe some friends have already started to use emoticons in their accounts after reading the tutorial. In fact, I hope that while copying the Unified version and SoftBank version of the emoticon code tables I pasted, you can also learn about the various versions of emoticons, Unicode encodings and supplementary codes, and continue to expand your knowledge. , draw parallels by analogy, only in this way can you truly turn the knowledge I explain into your own, and be able to adapt to changes by remaining unchanged.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444564.htmlTechArticleIntroduction and Article Summary The 11th article gives the Unified version of the emoticon (emoji expression) code table, and Introduced how to send emoji expressions in WeChat public account development mode, and also...
Statement:
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