Home  >  Article  >  Backend Development  >  WeChat Public Account Development Tutorial Part 7 - Use of Line Breaks in Text Messages_PHP Tutorial

WeChat Public Account Development Tutorial Part 7 - Use of Line Breaks in Text Messages_PHP Tutorial

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

This article mainly introduces the benefits of using line breaks in text messages and how to use line breaks.

Although I haven’t been able to find time to write a blog in the past month, I have been answering everyone’s questions seriously. It’s quite a sense of accomplishment to receive so many replies, attention and thanks. It makes me feel that doing this is more and more meaningful, and it strengthens my determination to continue writing. After the explanations in the previous six articles, I believe that you who are reading the article have mastered the basic development knowledge of WeChat public accounts (based on Java), such as framework construction, API encapsulation, message reception and reply, etc.; the following series of articles will focus on To explain the skills in public account development and the development of practical functions (such as weather query, surrounding search, human-computer dialogue, etc.).

Benefits and examples of using line breaks

The benefit of using line breaks is to make the presentation of information more neat, beautiful and intuitive. Appropriate use of line breaks in text messages will make people feel comfortable, clear and clear after reading them. The following is an example of the main menu of the public account xiaoqrobot. It uses line breaks reasonably. Doesn’t it look very intuitive and refreshing? (What? Do you think it’s ugly? Well, then it’s just me being narcissistic...)

You can imagine what it would look like if this text menu did not use a line break?

How to use line breaks in text messages?

In the text message of the WeChat public account, the line break character is still "n". Let's use the code to explain how the text menu of xiaoqrobot is implemented?

/**
	 * xiaoqrobot的主菜单
	 * 
	 * @return
	 */
	public static String getMainMenu() {
		StringBuffer buffer = new StringBuffer();
		buffer.append("您好,我是小q,请回复数字选择服务:").append("\n\n");
		buffer.append("1  天气预报").append("\n");
		buffer.append("2  公交查询").append("\n");
		buffer.append("3  周边搜索").append("\n");
		buffer.append("4  歌曲点播").append("\n");
		buffer.append("5  经典游戏").append("\n");
		buffer.append("6  美女电台").append("\n");
		buffer.append("7  人脸识别").append("\n");
		buffer.append("8  聊天唠嗑").append("\n\n");
		buffer.append("回复“?”显示此帮助菜单");
		return buffer.toString();
	}

How about it? Is it very simple to implement?

1) Lines 9-16 are menu items, and menu items are separated by a newline character;

2) Two line breaks are used at the end of line 8 and line 16, which can separate the menu items from other content, make it more layered, and look more comfortable and intuitive.

Perhaps attentive friends have discovered: In the screenshot, there is a "gift" emoticon behind "Peripheral Search" and "Beauty Radio", but you don't see it in the code. I removed this specifically because I I plan to use a dedicated article later to explain clearly the sending, processing, and receiving of QQ emoticons.

Details determine success or failure!


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444570.htmlTechArticleThis article mainly introduces the benefits of using line breaks in text messages and how to use line breaks. Although I have not been able to find time to write a blog in the past month, I have been seriously responding to everyone’s questions...
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