Public platform development (102) template message, 102 Template
Keyword: public platform template message
Author: Fang Times studio
Original article: http://www.cnblogs.com/txw1958/p/wechat-template-message.html
In this 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 consists of the following three parts:
I. Apply for template message Permissions
To apply for a template message, you must have activated the payment permission for the account.
In the background of the public platform, choose "function"> "add function plug-in"> "template message" to apply for a template message.
Send by calling the SDK. The Code is as follows:
1 require_once('weixin.class.php');2 $weixin = new class_weixin();3 var_dump($weixin->send_template_message(urldecode(json_encode($template))));
The implementation result is as follows:
4. Download Code
Please follow the public account of Fang Times studio and Reply to "Download template"
========================================================== ====
Follow-up methods for fanwe public platform accounts:
1. Address Book-Add friends-search for Public Accounts-search for "fangtimes Studio"
2. Address Book-add friend-search number-Enter "pondbaystudio"
3. Scan the following QR code
The developer mode of the public platform replies the text message code. It is best to have a full set of text instructions.
$ ResultStr = "<xml> \ n <ToUserName> <! [CDATA [". $ fromUsername."]> </ToUserName> \ n <FromUserName> <! [CDATA [". $ toUsername."]> </FromUserName> \ n <CreateTime> ". time ()." </CreateTime> \ n <MsgType> <! [CDATA [news]> </MsgType> \ n <ArticleCount> 1 </ArticleCount> \ n <Articles> \ n <item> \ n <Title> <! [CDATA ["Title"]> </Title> \ n <Description> <! [CDATA [Click to read the full text for details]> </Description> \ n <PicUrl> <! [CDATA [". $ picurl [" roster_pic "]."]> </PicUrl> \ n <Url> <! [CDATA [". 'www .baidu.com '. "]> </Url> \ n </item> \ n </Articles> \ n <FuncFlag> 0 </FuncFlag> \ n </xml> "; echo $ resultStr; $ resultStr = sprintf ($ newsTpl, $ fromUsername, $ toUsername, time (), $ msgType, $ title, $ desription ); after reading your $ newsTpl statement, it should be a defined template followed by a replaced parameter. Therefore, you can check whether the template is correct.
Here is an example used in my code. Replace the strings with your own strings.
Hope you can adopt it! Thank you.
Public platform reply text message template can hide date and change default view full text link
These are fixed styles that do not support customization.