callmez\wechat\sdk\Wechat::checkSignature PHP Method

checkSignature() public method

微信服务器请求签名检测
public checkSignature ( string $signature = null, string $timestamp = null, string $nonce = null ) : boolean
$signature string 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
$timestamp string 时间戳
$nonce string 随机数
return boolean
    public function checkSignature($signature = null, $timestamp = null, $nonce = null)
    {
        $request = Yii::$app->request;
        $signature === null && ($signature = $request->get('signature', ''));
        $timestamp === null && ($timestamp = $request->get('timestamp', ''));
        $nonce === null && ($nonce = $request->get('nonce', ''));
        $tmpArr = [$this->token, $timestamp, $nonce];
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode($tmpArr);
        return sha1($tmpStr) == $signature;
    }
Wechat