case "单图文":
$content = array();
$content[] = array('Title'=>'imooc',
'Description'=>"imooc is very cool",
'PicUrl'=>'http://www.imooc.com/static/img/common/logo.png',
'Url'=>'http://www.imooc.com',);
break;
---------------------------------------------------------
private function transmitNews($object, $newsArray)
{
$toUser = $object->FromUserName;
$fromUser = $object->ToUserName;
//$arr = array($newsArray);
/*
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>12345678</CreateTime>
<MsgType><![CDATA[news]]></MsgType>
<ArticleCount>2</ArticleCount>
<Articles>
<item>
<Title><![CDATA[title1]]></Title>
<Description><![CDATA[description1]]></Description>
<PicUrl><![CDATA[picurl]]></PicUrl>
<Url><![CDATA[url]]></Url>
</item>
</Articles>
</xml> */
$template = "<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<ArticleCount>1</ArticleCount>
<Articles>";
// foreach($arr as $v)
// {
$template .="<item>
<Title><![CDATA[".$newsArray['Title']."]]></Title>
<Description><![CDATA[".$newsArray['Description']."]]></Description>
<PicUrl><![CDATA[".$newsArray['PicUrl']."]]></PicUrl>
<Url><![CDATA[".$newsArray['Url']."]]></Url>
</item>";
// }
$template .="</Articles>
</xml> ";
// sprintf($template, $toUser, $fromUser, time(), 'news');
echo sprintf($template, $toUser, $fromUser, time(), 'news');
Guard丿星魂