为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我的老是回复不了

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');

}


正在回答

1 回答

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');

}


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么我的老是回复不了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信