微信公众平台图文模式测试
2017-01-07 21:03
246 查看
public function responseMsg() { //get post data, May be due to the different environments $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; //extract post data if (!empty($postStr)){ /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection, the best way is to check the validity of xml by yourself */ libxml_disable_entity_loader(true); $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim($postObj->Content); $time = time(); $textTpl = "<xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%s</CreateTime> <MsgType><![CDATA[news]]></MsgType> <ArticleCount><![CDATA[3]]></ArticleCount> <Articles> <item> <Title><![CDATA[haha,mt1]]></Title> <Description><![CDATA[test1]]></Description> <PicUrl><![CDATA[http://www.test.com/test.jpg]]></PicUrl> <Url><![CDATA[http://www.baidu.com]]></Url> </item> <item> <Title><![CDATA[haha,mt2]]></Title> <Description><![CDATA[test1]]></Description> </item> <item> <Title><![CDATA[haha,mt3]]></Title> <Description><![CDATA[test1]]></Description> </item> </Articles> </xml>"; if(!empty( $keyword )) { $msgType="news"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType); echo $resultStr; }else{ echo "Input something..."; } }else { echo ""; exit; } }
相关文章推荐
- 微信公众平台开发者模式(2)JAVA自动回复文本消息及多图文消息
- 微信公众平台图文教程(五)编辑模式
- 微信公众平台开发模式启用及接口配置图文教程
- 跟我学XSL(4)测试模式
- C学习之------CPU大、小端模式测试
- 仿照单子模式的测试
- 【分享】索爱手机测试模式
- [翻译]基于用户体验的性能测试:第三章 模拟个别的用户模式
- 《半条命2》多人模式火热尝鲜!正式版测试截图
- OPTA 7模式测试说明
- (已测试)在本地处理模式下将数据库数据源与 ReportViewer Web 服务器控件一起使用
- Motorola新智能手机测试Linux(图文!)
- 转:JAVA测试模式
- 单元测试中的常用测试模式
- 浅议DAS、NAS、SAN三种模式[图文推荐]
- 跟我学XSL(4)测试模式
- 另一种思考模式,在软件测试中成长......
- 测试模式 - XSL教程 - 5
- 安全测试模式范例
- 测试显示模式_X86汇编