qq_位卑未敢忘忧国_0
2016-03-17 17:53
$MType = strtolower($postObj->MsgType);
$toUser = $postObj->FromUserName;
$fromUser = $postObj->ToUserName;
if($MType=='text'){
$info =reponseNews($toUser,$fromUser);
echo $info ;
}
function reponseNews($toUser,$fromUser){
$arr = array(
array(
'title'=>'ganmiao',
'description'=>"ganmiao is very cool",
'picUrl'=>'http://www.ganmiao.com/3.jpg',
'url'=>'http://www.ganmiao.com/wap.php',
),
array(
'title'=>'hao123',
'description'=>"hao123 is very cool",
'picUrl'=>'https://www.baidu.com/img/bdlogo.png',
'url'=>'http://www.hao123.com',
),
array(
'title'=>'qq',
'description'=>"qq is very cool",
'picUrl'=>'http://www.imooc.com/static/img/common/logo.png',
'url'=>'http://www.qq.com',
),
);
$CreateTime = time();
$MsgType = 'news';
//$ArticlesCount= 1;
$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> ";
$info = sprintf($template,$toUser,$fromUser,$CreateTime,$MsgType);
return $info;
}
使用非外网图片要提前上传
PHP实现微信公众平台开发—提升篇
64949 学习 · 371 问题
相似问题