Home >Backend Development >PHP Tutorial >WeChat public platform development (102) template message, 102 template_PHP tutorial
Keywords: WeChat public platform template message
Author: Fangbei Studio
Original text: http ://www.cnblogs.com/txw1958/p/wechat-template-message.html
In this WeChat public platform development tutorial, we will introduce how to develop template messages, that is, how to use the program to send template messages.
This article is divided into the following three parts:
To apply for template messages, the account must have activated WeChat payment permissions.
In the backend of the WeChat public platform, enter "Function->Add Function Plug-in->Template Message" to apply for template messages.
Call SDK to send, the code is as follows
<span>1</span> <span>require_once</span>('weixin.class.php'<span>); </span><span>2</span> <span>$weixin</span> = <span>new</span><span> class_weixin(); </span><span>3</span> <span>var_dump</span>(<span>$weixin</span>->send_template_message(<span>urldecode</span>(json_encode(<span>$template</span>))));
The effect is as follows:
Please follow Fangbei Studio’s WeChat public account and reply “Download template”
==============================================
How to follow the Fangbei Studio WeChat public platform account:
1. WeChat address book-add friend-search public account-search for "Fangbei Studio"
2. WeChat address book-add friend-search Number - enter "pondbaystudio"
3. Use WeChat to scan the QR code below
$resultStr="b2a0af5a8fd26276da50279a1c63a57a\n ea5d8177d19f22584533e5c37c389942f88247afc5b8a5f946eae2bdf66a4bbc6671a89dce89e879d9e9c6d81d03862b\n c5123754d1f4829fae4905e8abb602f9059cfaa4e56d4e1617a6e2c2e8a247aa42a4b8d57eb0afadcf16b7a02c69caaf\n 246311df1688542638dc52b54a1a4c87".time()."e660f1169ff44ea75c5a982fcb1cde61\n 42815c2206ae835d7fd68cb4ae21e4df9ac84bfa39510e5f32804c328c4f3e00 698463fc03844fbe5a9caafaa1ebd0b1\n b291e929c3635e406ae149be43c4dea51e2ad4413ec6d8ee7b6cdf3cce8af5c33\n a0cc616e132e8f145efe3203f0adecf4\n 5083cbefc9e5095dae6431462e2af988\n 17f99421ef144bd8646414dee5ba4771f0d3ece2cb732fe7b16cc465f74a97768e005604ecdfae803531b5819ee490f8 \n 96e24a1c1610e98f0f6cd9c052664a05c03b45031a7581e1b8c4c4da191bbf35014a5ca517c5f72dd0cb1b67f611a4e7\n 3259474b39e06f6878eefac5903f4d30ad50bc7d8f19a95792ad066c096875da5022051692ecec35593d03d066a910e1\n 050d455051be28905fa4a6508257ceafb559e1fc69875c0c60b9658abfdd86a4e041dc07ad454be4d3524f3164ef8b6b\n 6d04af7aa1cc3096ed7e7b950e1ecf7f\ n 427dbd474c922e6c2de2e5cf19fbb494\n c16e87311aa318186a2141a5b8ce55110fecc2d83bf66fbc799a88f710e0cd251\n 21118965b89073f60271ef4a3b5d3c58";echo $resultStr;$resultStr = sprintf($newsTpl, $fromUsername, $toUsername, time(), $msgType , $title,$desription); After reading your sentence, $newsTpl should be a defined template, followed by the replacement parameters, so you can check whether the template is correct
I will give you the one used in my code Let’s take an example. Replace the specific strings yourself
I hope you can adopt it! Thank you
These are fixed styles and do not support customization.