奈斯涂咪涂u
2018-09-12 17:51
if (strtolower($postObj->MsgType) == 'text' && trim($postObj->Content) == 'tuwen1') { $toUser = $postObj->FromUserName; $fromUser = $postObj->ToUserName; $arr = array( array( 'title' => 'niubi', 'description' => 'niubihahahahaha', 'picUrl' => 'http://www.w3school.com.cn/i/eg_tulip.jpg', 'url' => 'http://www.imooc.com', ), ); $template = "<xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%s</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <ArticleCount>".count($arr)."</ArticleCount> <Articles>"; foreach($arr as $k=>$v){ $template .= "<item> <Title><![CDATA[".$v['title']."]]></Title> <Description><![CDATA[".$v['description']."]]></Description> <PicUrl><![CDATA[".$v['picUrl']."]]></PicUrl> <Url><![CDATA[".$v['url']."]]></Url> </item>"; } $template .= "</Articles> </xml>"; echo sprintf($template,$toUser,$fromUser,time(),'news'); }
if (strtolower($postObj->MsgType) == 'text' && trim($postObj->Content) == 'tuwen1') { $toUser = $postObj->FromUserName; $fromUser = $postObj->ToUserName; $arr = array( array( 'title' => 'niubi', 'description' => 'niubihahahahaha', 'picUrl' => 'http://www.w3school.com.cn/i/eg_tulip.jpg', 'url' => 'http://www.imooc.com', ), ); $template = "<xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%s</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <ArticleCount>".count($arr)."</ArticleCount> <Articles>"; foreach($arr as $k=>$v){ $template .= "<item> <Title><![CDATA[".$v['title']."]]></Title> <Description><![CDATA[".$v['description']."]]></Description> <PicUrl><![CDATA[".$v['picUrl']."]]></PicUrl> <Url><![CDATA[".$v['url']."]]></Url> </item>"; } $template .= "</Articles> </xml>"; echo sprintf($template,$toUser,$fromUser,time(),'news'); }
PHP实现微信公众平台开发—提升篇
64923 学习 · 258 问题
相似问题
回答 2
回答 1