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

不走else区间 这样的情况有大佬出现过吗

不用框架的时候 都好使 用了tp5  然后用的route路由 微信配置中的url是 http://www.xxxx/api/wei/check  token 认证是可以的 我在else区间调用了关注回复 但是没有回复  然后我调用了自定义菜单(测试走不走else区间)还是不行 单独用自定义菜单是可以的 哪位大佬出现过这个情况

public function check_wei()

    {

        if(isset($_GET['echostr'])) {

            $nonce     = $_GET['nonce'];

            $token     = 'bijiwang123456';

            $timestamp = $_GET['timestamp'];

            $echostr   = $_GET['echostr'];

            $signature = $_GET['signature'];

            $array = array($nonce, $timestamp, $token);

            sort($array);

            $str = sha1(implode($array));

            if($str == $signature ) {

                echo $echostr; 

                exit;

            }

        }

         $this->sendMsg();

        

    }

    public function sendMsg()

    {

        $post_data = file_get_contents('php://input');//获得微信推送过得post数据(xml格式)

        file_put_contents('ceshi.txt',$post_data);

        $post_obj = simplexml_load_string($post_data);//处理消息

        if(strtolower($post_obj->MsgType) == 'event') {//判断是否是订阅的时间推送

            if(strtolower($post_obj->Event) == 'subscribe') {//判断是否是关注事件

                $toUser = $post_obj->FromUserName;

                $fromUser = $post_obj->ToUserName;

                $time = time();

                $msgType = 'text';

                $content = '欢迎关注';

                $template = "

                    <xml>

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

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

                    <CreateTime>%s</CreateTime>

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

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

                    </xml>

                ";

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

                echo $info;

            }

        }

    }


正在回答

0 回答

举报

0/150
提交
取消

不走else区间 这样的情况有大佬出现过吗

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号