ccdr
public function actionIndex(){
        $nonce = Yii::$app->request->get(\'nonce\');
        $token = \'adshare\';
        $timestamp = Yii::$app->request->get(\'timestamp\');
        $echostr = Yii::$app->request->get(\'echostr\');
        $signature = Yii::$app->request->get(\'signature\');
        $array = array();
        $array = array($nonce,$timestamp,$token);
        sort($array);
        $str = sha1(implode($array));

        /*if($str == $signature){
            echo $echostr;
        }*/
        if($str == $signature && $echostr){
            return $echostr;
        }else{
            self::actionMessage();
        }
    }

 

 

注意方法中被注释的代码,不管是初次还是再次修改,都需要把$echostr返回给微信,才能正确验证,否则会一直提示token的问题!

分类:

技术点:

相关文章: