case '成都': //
$content = array();
$content[] = array("Title" =>"现场直播|xxxxxxxx峰会-成都",
"Description" =>"xxxxxx高端盛宴",
"PicUrl" =>"http://xxx.xxx.com/files/user/fenghui/meeting/img/chengdu.png?20190313",
"Url" =>"https://xxx.xxx.com/live/5534154?openid=".$postObj->FromUserName);
$this->transmitNews($postObj, $content);
exit();
break;
private function transmitNews($object, $newsArray)
{
if(!is_array($newsArray)){
return;
}
$itemTpl = " <item>
<Title><![CDATA[%s]]></Title>
<Description><![CDATA[%s]]></Description>
<PicUrl><![CDATA[%s]]></PicUrl>
<Url><![CDATA[%s]]></Url>
</item>
";
$item_str = "";
foreach ($newsArray as $item){
$item_str .= sprintf($itemTpl, $item['Title'], $item['Description'], $item['PicUrl'], $item['Url']);
}
$xmlTpl = "<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[news]]></MsgType>
<ArticleCount>%s</ArticleCount>
<Articles>
$item_str</Articles>
</xml>";
$result = sprintf($xmlTpl, $object->FromUserName, $object->ToUserName, time(), count($newsArray));
//return $result;
echo $result;die();
}