微信SDK关键词触发事件触发不灵验

浏览:2020 发布日期:2014/10/13 分类:求助交流 关键字: 微信SDK
<?php
class WeixinAction extends CommonAction {
   public function index(){
        import('@.ORG.Util.ThinkWechat');
        $weixin = new ThinkWechat('tte');
        /* 获取请求信息 */
        $data = $weixin->request();
        
        list($content, $type) = $this->reply($data);
        /* 响应当前请求 */
        $weixin->response($content, $type);
        $this->LogInfo($data);
    }
    private function reply($data){
        if('text' == $data['MsgType']){
            switch ($data['Content']) {
                case '1':
                    $ae[0]=array(
                        '论坛区',
                        '更多咨询在这里!',
                        "http://".$_SERVER["HTTP_HOST"]."/Fruit/Tpl/Mobile/Public/Images/gtxshop.jpg",
                        "http://".$_SERVER["HTTP_HOST"]."/index.php/Fruit/shop/openid/".$data['FromUserName']
                    );
                    $reply=array($ae,'news');
                    break;
                case '2':
                    $aii[0]=array(
                        '官网',
                        '讯息发布!',
                        "http://".$_SERVER["HTTP_HOST"]."/Fruit/Tpl/default/Public/Images/fpweb.jpg",
                        "http://".$_SERVER["HTTP_HOST"]."/index.php/Fruit/pweb/openid/".$data['FromUserName']
                    );
                    $reply=array($aii,'news');
                    break;
                default:
                    $reply = array("欢迎关注", 'text');
                    break;
            }
        }elseif('event' == $data['MsgType'] && 'subscribe' == $data['Event']){
            $reply = array("欢迎关注", 'text');
        }elseif('event' == $data['MsgType'] && 'unsubscribe' == $data['Event']){
            $reply = array("欢迎再来", 'text');
        }else{
            exit;
        }
        return $reply;
    }
}
引用http://www.thinkphp.cn/extend/370.html微信SDK
我这样写的,关键词触发自动回复不灵验,时有时无,还有关注事件触发回复也是如此,不知道哪个地方错了,求大神指点呀!!在线等
最佳答案
评论( 相关
后面还有条评论,点击查看>>