问答详情
源自:2-5 自定义菜单的事件推送验证及总结

有没有点击回复多图文信息的例子啊

自定义菜单下  能不能点击后推送多图文信息,能不能给个事例!!!

提问者:慕神0356814 2016-08-24 10:44

个回答

  • 小朋宇吃西红柿
    2016-09-06 10:42:54
    已采纳

    获取点击后调用这个方法回复多图文啊


    public function temp(){

    $arr = array(array('title' => 'imooc', 

    'description'=>'desc',

    'picurl'=>'http://mmbiz.qpic.cn/mmbiz_png/h06yWNicL3Vd15sic9u0ba7mxCKYEr57M0zkE3n8HcPLSFqtwJa5n1pUTTkPicK9icFty8U9scNrskReDtJ0nS7s5g/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1',

    'url'=>'http://mp.weixin.qq.com/s?__biz=MzA5MDE3MTc2OA==&mid=2650354371&idx=1&sn=bd8286941d849c11d6a548494c4f9255&scene=18#wechat_redirect'

    ),array('title' => 'imooc', 

    'description'=>'desc',

    'picurl'=>'http://mmbiz.qpic.cn/mmbiz_png/h06yWNicL3Vd15sic9u0ba7mxCKYEr57M0zkE3n8HcPLSFqtwJa5n1pUTTkPicK9icFty8U9scNrskReDtJ0nS7s5g/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1',

    'url'=>'http://mp.weixin.qq.com/s?__biz=MzA5MDE3MTc2OA==&mid=2650354371&idx=1&sn=bd8286941d849c11d6a548494c4f9255&scene=18#wechat_redirect'

    ),

    array('title' => 'imooc', 

    'description'=>'desc',

    'picurl'=>'http://mmbiz.qpic.cn/mmbiz_png/h06yWNicL3Vd15sic9u0ba7mxCKYEr57M0zkE3n8HcPLSFqtwJa5n1pUTTkPicK9icFty8U9scNrskReDtJ0nS7s5g/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1',

    'url'=>'http://mp.weixin.qq.com/s?__biz=MzA5MDE3MTc2OA==&mid=2650354371&idx=1&sn=bd8286941d849c11d6a548494c4f9255&scene=18#wechat_redirect'

    ),

    );

    //多图文时候不能超过10个

    $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>";

    return $template;

    }

    echo sprintf($template, $toUser, $fromUser, $time, $msgType, $content);