WeChat public platform development (102) template message, 102 Template

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.