123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- /**
- * Created by 上海风车教育科技有限公司.
- * User: 刘红伟
- * Date: 15-11-26
- * Email: 454303753@qq.com
- * File:wechattemplate.php
- */
- class wechattemplate{
- const MSG_TYPE = 1;
- private $tpl;
- public function __construct($type=self::MSG_TYPE){
- switch($type){
- case 'test':
- $this->_text();
- break;
- case 'image':
- $this->_image();
- break;
- case 'voice':
- $this->_voice();
- break;
- case 'video':
- $this->_video();
- break;
- case 'music':
- $this->_music();
- break;
- case 'news':
- $this->_news();
- break;
- default:
- $this->_text();
- }
- }
- private function _text(){
- $this->tpl="<xml>
- <ToUserName><![CDATA[%s]]></ToUserName>
- <FromUserName><![CDATA[%s]]></FromUserName>
- <CreateTime>%s</CreateTime>
- <MsgType><![CDATA[text]]></MsgType>
- <Content><![CDATA[%s]]></Content>
- </xml>";
- }
- private function _image(){
- $this->tpl="<xml>
- <ToUserName><![CDATA[%s]]></ToUserName>
- <FromUserName><![CDATA[%s]]></FromUserName>
- <CreateTime>%s</CreateTime>
- <MsgType><![CDATA[image]]></MsgType>
- <Image>
- <MediaId><![CDATA[%s]]></MediaId>
- </Image>
- </xml>";
- }
- private function _voice(){
- $this->tpl="
- <xml>
- <ToUserName><![CDATA[%s]]></ToUserName>
- <FromUserName><![CDATA[%s]]></FromUserName>
- <CreateTime>%s</CreateTime>
- <MsgType><![CDATA[voice]]></MsgType>
- <Voice>
- <MediaId><![CDATA[%s]]></MediaId>
- </Voice>
- </xml>
- ";
- }
- private function _video(){
- $this->tpl="
- <xml>
- <ToUserName><![CDATA[%s]]></ToUserName>
- <FromUserName><![CDATA[%s]]></FromUserName>
- <CreateTime>%s</CreateTime>
- <MsgType><![CDATA[video]]></MsgType>
- <Video>
- <MediaId><![CDATA[%s]]></MediaId>
- <Title><![CDATA[%s]]></Title>
- <Description><![CDATA[%s]]></Description>
- </Video>
- </xml>
- ";
- }
- private function _music(){
- $this->tpl="
- <xml>
- <ToUserName><![CDATA[%s]]></ToUserName>
- <FromUserName><![CDATA[%s]]></FromUserName>
- <CreateTime>%s</CreateTime>
- <MsgType><![CDATA[music]]></MsgType>
- <Music>
- <Title><![CDATA[%s]]></Title>
- <Description><![CDATA[%s]]></Description>
- <MusicUrl><![CDATA[%s]]></MusicUrl>
- <HQMusicUrl><![CDATA[%s]]></HQMusicUrl>
- <ThumbMediaId><![CDATA[%s]]></ThumbMediaId>
- </Music>
- </xml>
- ";
- }
- private function _news(){
- $this->tpl="
- <xml>
- <ToUserName><![CDATA[%s]]></ToUserName>
- <FromUserName><![CDATA[%s]]></FromUserName>
- <CreateTime>%s</CreateTime>
- <MsgType><![CDATA[news]]></MsgType>
- <ArticleCount>1</ArticleCount>
- <Articles>
- <item>
- <Title><![CDATA[%s]]></Title>
- <Description><![CDATA[%s]]></Description>
- <PicUrl><![CDATA[%s]]></PicUrl>
- <Url><![CDATA[%s]]></Url>
- </item>
- </Articles>
- </xml>
- ";
- }
- public function getTpl(){
- return $this->tpl;
- }
- }
|