问答详情
源自:5-3 验证单图文

我的输不出图文消息,而且一直报错:该公众号提供的服务出现故障,请稍后再试

$arr = array(

array(

'title'=>"扫福",

'description'=>"给你发个福字",

'picurl'=>"http://www.imooc.com/static/img/common/logo.png",

'url'=>"https://www.baidu.com",

),

);

$template = "<xml>

<ToUserName><![CDATA[%s]]></ToUserName>

<FromUserName><![CDATA[%s]]></FromUserName>

<CreateTime>%u</CreateTime>

<MsgType><![CDATA[%s]]></MsgType>

<ArticleCount>".count($arr)."</ArticleCount>

<Articles>";

foreach ($arr as $val){

$template .= "<item>

  <Title><![CDATA[".$val['title']."]]></Title>

  <Description><![CDATA[".$val['description']."]]></Description>

  <PicUrl><![CDATA[".$val['picurl']."]]></PicUrl>

  <Url><![CDATA[".$val['url']."]]></Url>

  </item>";

}

$template .= "</Articles>

  </xml>";

$template = trim($template);

$info = sprintf($template,$toUsername,$fromUserName,$time,'news');

echo $info;


提问者:慕粉4066171 2018-02-07 17:58

个回答

  • 慕仔8564313
    2018-02-11 23:37:21

    <CreateTime>%u</CreateTime>,   这里是%s ,代表字符串   对应的  $time