亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home WeChat Applet WeChat Development WeChat applet implements sending template messages

WeChat applet implements sending template messages

May 09, 2018 pm 09:50 PM
Applets template information

WeChat Mini Program You Draw I Guess demo complete source code WeChat Mini Program Consumption Calculator demo complete source code WeChat Mini program imitates Shanlinbao demo complete source code

WeChat mini program imitates Bilibili Video Station demo complete source code WeChat mini program simple metronome demo complete source code

Chaige WeChat Mini Program Application Store Source Code WeChat Mini Program demo: Guoku updated version WeChat Mini Program demo: Yang Tao

WeChat mini program demo: Zhihu Daily Recommended demo for learning WeChat mini program: chat room + audio and video + adding content + Baidu translation

Click the tabbar to change icon WeChat mini program demo: imitation mall WeChat mini program demo: imitation NetEase Cloud Music

Simple Left swipe operation and waterfall flow layout More mini program template source code

This article mainly shares with you the WeChat mini program to implement sending template messages, which is different from the official account sending template messages. There is no subscription (following) in the mini program, so there is no way to push messages to users through the dialogue window. Template messages issued by the mini program are uniformly sent through WeChat "Service Notification", as shown below:

But its implementation The process is the same as sending template messages from public accounts. The steps are as follows:
1. Obtain access_token
access_token is a globally unique interface calling credential. Developers need to use access_token when calling each interface and need to keep it properly. I have done WeChat development and public account development, which are the most basic. The method of obtaining access_token here is exactly the same as that of public account. For the method, see: Obtain WeChat basic interface credential Access_token

2. Add template message
and follow The same as the official account, you need to add a template message in the background of the mini program, and then obtain the corresponding template message ID.

3. Send template message
According to the template message keyword corresponding to the template message ID, the message content is constructed on the backend. When the user submits the form or makes payment, the form_id is obtained (in the form submission scenario, It is the formId brought in the submit event; in the payment scenario, it is the prepay_id of this payment), and then the end sends the message. The message parameters are as follows:

The code implementation example is as follows:

function sendtpl(){
	$accessToken = 'xxxxxxxxxxxxxxxxxxxxxx';
	$postData = array(
		"touser"		=>'xxxxxxxxxxxxxxxxxxxxxx',  	//用戶openid
		"template_id"	=>'xxxxxxxxxxxxxxxxxxxxxx', 	//模板消息ID
		"page"			=>'pages/index/index',          
		"form_id"		=>'xxxxxxxxxxxxxxxxxxxxxx',   	//表單提交場景下,事件帶上的 formId;支付場景下,為本次支付的 prepay_id 
		"data"			=>array(
				'keyword1'	=> array('value'=>'港榮蒸蛋糕','color'=>'#000000'),
				'keyword2'	=> array('value'=>'您購買的的港榮蒸蛋糕已經(jīng)發(fā)貨,點擊進(jìn)入小程序查看詳情','color'=>'#000000')
			),
		'emphasis_keyword'=>''
	);
	$postData =  json_encode($postData,JSON_UNESCAPED_UNICODE);
	$url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token={$accessToken}";
	$rtn = request($url,true,'POST',$postData);
	
	return $rtn;
}

Related recommendations:

Implement WeChat applet Unrestricted template messages, unlimited active push

PHP implementation of WeChat template message example

WeChat development template message reply

The above is the detailed content of WeChat applet implements sending template messages. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
What does it mean when a message has been sent but rejected by the other party? What does it mean when a message has been sent but rejected by the other party? Mar 07, 2024 pm 03:59 PM

The message has been sent but rejected by the other party. This means that the sent information has been successfully sent from the device, but for some reason, the other party did not receive the message. More specifically, this is usually because the other party has set certain permissions or taken certain actions, which prevents your information from being received normally.

How to swipe right and reply quickly in iMessage on iOS 17 How to swipe right and reply quickly in iMessage on iOS 17 Sep 20, 2023 am 10:45 AM

How to Use Swipe to Reply in iMessages on iPhone Note: The Swipe to Reply feature only works with iMessage conversations in iOS 17, not regular SMS conversations in the Messages app. Open the Messages app on your iPhone. Then, head to the iMessage conversation and simply swipe right on the iMessage you want to reply to. Once this is done, the selected iMessage will be in focus while all other messages will be blurred in the background. You'll see a text box for typing a reply and a "+" icon for accessing iMessage apps like Check-ins, Places, Stickers, Photos, and more. Just enter your message,

Implement card flipping effects in WeChat mini programs Implement card flipping effects in WeChat mini programs Nov 21, 2023 am 10:55 AM

Implementing card flipping effects in WeChat mini programs In WeChat mini programs, implementing card flipping effects is a common animation effect that can improve user experience and the attractiveness of interface interactions. The following will introduce in detail how to implement the special effect of card flipping in the WeChat applet and provide relevant code examples. First, you need to define two card elements in the page layout file of the mini program, one for displaying the front content and one for displaying the back content. The specific sample code is as follows: <!--index.wxml-->&l

The message has been sent but was rejected by the other party. Should I block it or delete it? The message has been sent but was rejected by the other party. Should I block it or delete it? Mar 12, 2024 pm 02:41 PM

1. Being added to the blacklist: The message has been sent but rejected by the other party. Generally, you have been blacklisted. At this time, you will not be able to send messages to the other party, and the other party will not be able to receive your messages. 2. Network problems: If the recipient's network condition is poor or there is a network failure, the message may not be successfully received. At this point, you can try to wait for the network to return to normal before sending the message again. 3. The other party has set up Do Not Disturb: If the recipient has set up Do Not Disturb in WeChat, the sender’s messages will not be reminded or displayed within a certain period of time.

iOS 17: How to use emojis as stickers in Messages iOS 17: How to use emojis as stickers in Messages Sep 18, 2023 pm 05:13 PM

In iOS17, Apple has added several new features to its Messages app to make communicating with other Apple users more creative and fun. One of the features is the ability to use emojis as stickers. Stickers have been around in the Messages app for years, but so far, they haven't changed much. This is because in iOS17, Apple treats all standard emojis as stickers, allowing them to be used in the same way as actual stickers. This essentially means you're no longer limited to inserting them into conversations. Now you can also drag them anywhere on the message bubble. You can even stack them on top of each other to create little emoji scenes. The following steps show you how it works in iOS17

Alipay launched the 'Chinese Character Picking-Rare Characters' mini program to collect and supplement the rare character library Alipay launched the 'Chinese Character Picking-Rare Characters' mini program to collect and supplement the rare character library Oct 31, 2023 pm 09:25 PM

According to news from this site on October 31, on May 27 this year, Ant Group announced the launch of the "Chinese Character Picking Project", and recently ushered in new progress: Alipay launched the "Chinese Character Picking-Uncommon Characters" mini program to collect collections from the society Rare characters supplement the rare character library and provide different input experiences for rare characters to help improve the rare character input method in Alipay. Currently, users can enter the "Uncommon Characters" applet by searching for keywords such as "Chinese character pick-up" and "rare characters". In the mini program, users can submit pictures of rare characters that have not been recognized and entered by the system. After confirmation, Alipay engineers will make additional entries into the font library. This website noticed that users can also experience the latest word-splitting input method in the mini program. This input method is designed for rare words with unclear pronunciation. User dismantling

How to set up Xiaomi Mi 14 Pro to light up the screen for messages? How to set up Xiaomi Mi 14 Pro to light up the screen for messages? Mar 18, 2024 pm 12:07 PM

Xiaomi 14Pro is a flagship model with excellent performance and configuration. It has achieved high sales since its official release. Many small functions of Xiaomi 14Pro will be ignored by everyone. For example, it can be set to light up the screen for messages. Although the function is small, , but it is very practical. Everyone will encounter various problems when using the mobile phone. So how to set up the Xiaomi 14Pro to light up the screen for messages? How to set up Xiaomi Mi 14 Pro to light up the screen for messages? Step 1: Open your phone’s Settings app. Step 2: Swipe down until you find the "Lock screen and password" option and click to enter. Step 3: In the "Lock screen & passcode" menu, find and click the "Turn on screen for notifications" option. Step 4: On the "Turn on screen when receiving notifications" page, turn on the switch to enable

How uniapp achieves rapid conversion between mini programs and H5 How uniapp achieves rapid conversion between mini programs and H5 Oct 20, 2023 pm 02:12 PM

How uniapp can achieve rapid conversion between mini programs and H5 requires specific code examples. In recent years, with the development of the mobile Internet and the popularity of smartphones, mini programs and H5 have become indispensable application forms. As a cross-platform development framework, uniapp can quickly realize the conversion between small programs and H5 based on a set of codes, greatly improving development efficiency. This article will introduce how uniapp can achieve rapid conversion between mini programs and H5, and give specific code examples. 1. Introduction to uniapp unia

See all articles