Wechat public account development tutorial

Introduction and content summary

Several readers have complained that "Liu Feng only uses text messages as an example, never mentions graphic messages, and doesn't know how to use graphic messages". Well, I was wrong. I thought that by encapsulating the basic API and building the framework, and then giving an example of the use of text messages, you can follow the cat's example. Maybe it's because my painting skills are too poor, The cat drawn is not like a cat

This article mainly introduces the use of graphic messages in the development of wechat public account, as well as several forms of graphic messages. The title is called "full introduction to graphic news". This is definitely not the title party. It wants to take this opportunity to remove all the problems, doubts and obstacles related to graphic news.

Description of main parameters of graphic message

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

As can be seen from the figure:

Various forms of graphic messages

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

The function realized by the above code is that when the user sends numbers 1-5, the user will reply to graphic messages in five different forms, as follows:

a) The user sends 1 and replies to the single graphic message. Refer to lines 68 ~ 81 of code, and the operation effect is as follows:

b) Users send 2, reply single graphic message --- no pictures. Refer to lines 82 ~ 96 of code, and the operation effect is as follows:

Note: the title and description of graphic messages can contain QQ expressions and symbolic expressions.

c) The user sends 3 and replies to multiple graphic messages. Refer to lines 97 ~ 123 of code, and the operation effect is as follows:

Note: for multi graphic messages, the description will not be displayed. Line feed can be used in the title to make the display more beautiful.

d) The user sends 4 and replies to multiple text messages --- the first message does not contain pictures. Refer to lines 124 ~ 158 of code, and the operation effect is as follows:

e) The user sends 5 and replies to multiple graphic messages --- the last message does not contain pictures. Refer to lines 159 ~ 186 of code, and the operation effect is as follows:

It can be seen that graphic messages have rich content and diversified forms of expression. I hope you can use them reasonably according to their own characteristics and actual use needs.

Finally, based on my practical experience, I would like to make a summary of the use of graphic messages:

1) Be sure to assign a value to the URL attribute of the text message. Whether it is a single picture, multiple pictures, or pictures without pictures, it may be clicked by users. If the URL is empty, the user will open a blank page after clicking, which gives the user a very poor experience;

2) Only the description of a single picture and text will be displayed, and the description of multiple pictures and text will not be displayed;

3) QQ emoticons and symbolic emoticons can be used in the title and description of graphic messages. Rational use of emoticons will make the message more vivid;

4) Line breaks can be used in the title and description of graphic messages. Rational use of line breaks will make the content structure clearer;

5) Title of graphic message Hypertext links are not supported in descriptions (HTML < a > tag). It's not only technically impossible, but also logically impossible, because if a graphic message is clicked anywhere, it will call the wechat built-in browser to open the URL. If several hyperlinks are placed in the title and description, I don't know which page to open. I really don't understand why several students are asking this question, isn't it Isn't Chengduo good?

6) Links to graphic messages and pictures can use resources under external domain names. For example, in this example, Liu Feng's Avatar and blog links are resources pointing to CSDN website. On the Internet, even in the wechat official communication group, many people think that the URL and picurl of graphic messages can not be used outside the chain. They don't know where the rumor began. Practice is the only standard to test the truth!

7) Use a picture of the specified size. The recommended size of the first picture is 640 * 320, and that of other pictures is 80 * 80. If the image used is too large, the loading is slow and consumes traffic; If the image used is too small, it will be stretched after display, distorted and ugly.

8) It is recommended to control the number of pictures and texts of each picture and text message to 1-4. In this way, one screen can be displayed on most terminals, and users can roughly understand the main content of the message at a glance, which is most likely to prompt users to click and read.

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>