[Php] WeChat public account development interface

Source: Internet
Author: User
On the public platform, developers can send emojis to users. For example, QQ expressions and symbolic expressions. Qq expressions are easy to send. Although QQ expressions are displayed as emojis, they are text messages on the public platform. Each expression has a unique code corresponding to it. For example, if the first expression is "Smile", there are three types of expressions: smile; [Smile];:)

On the public platform, developers can send emojis to users. For example, QQ expressions and symbolic expressions. Qq expressions are easy to send. Although QQ expressions are displayed as emojis, they are text messages on the public platform. Each expression has a unique code corresponding to it. For example, the first expression "Smile" has three Representation Methods:/smile; [Smile];/: :)

On the public platform, developers can send emojis to users. For example, QQ expressions and symbolic expressions. Qq expressions are easy to send. Although QQ expressions are displayed as emojis, they are text messages on the public platform. Each expression has a unique code corresponding to it. For example, the first expression "Smile" has three Representation Methods:/smile; [Smile];/: :), you can directly send a QQ expression to the user by passing such a parameter to the contentStr of the message interface. The method in this example is very simple and I will not repeat it here.


Here, I mainly want to explain how to send symbolic expressions to users in the php environment.

The essence of a symbolic expression is also a text message. However, unlike the QQ expression, it is unicode encoded. If it is directly sent, it will be output as is. Developers need to encode and convert it. See the Code:

Public function emoji ($ emoji_str) {// combines strings into json format $ emoji_str = '["'. $ emoji_str. '"]'; $ emoji_arr = json_decode ($ emoji_str, true); if (count ($ emoji_arr) = 1) return $ emoji_arr [0]; elsereturn null ;}
The json_decode method is provided in php5.0 and later versions. JSON is a data storage format. It is very popular. It is really like an array. For more details, please refer to the relevant materials. We first convert the string to the array format, and then use the json_decode method. In this way, unicode encoding can be converted to UTF-8 encoding.

Call this function where you want to display a symbolic expression, for example:

$ ContentStr = "[muscle]". $ this-> emoji ($ emoji_str = "\ ue14c ");


For more emoticon code and implementation methods, see the following link:

Liu Feng's column

Emoji for PHP

For the bsdcfp column, please respect the hard work of others. Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.