46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the overtrue/wechat.
|
|
*
|
|
* (c) overtrue <i@overtrue.me>
|
|
*
|
|
* This source file is subject to the MIT license that is bundled
|
|
* with this source code in the file LICENSE.
|
|
*/
|
|
|
|
namespace TuzhiEasyWeChat\Channels\Server;
|
|
|
|
use TuzhiEasyWeChat\Kernel\ServerGuard;
|
|
use TuzhiEasyWeChat\Kernel\Encryptor;
|
|
/**
|
|
* Class Guard.
|
|
*
|
|
* @author overtrue <i@overtrue.me>
|
|
*/
|
|
class Guard extends ServerGuard
|
|
{
|
|
protected function shouldReturnRawResponse(): bool
|
|
{
|
|
return !is_null($this->app['request']->get('echostr'));
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*
|
|
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
|
*/
|
|
protected function decryptMessage(array $message)
|
|
{
|
|
$encryptor = new Encryptor($this->app['config']->get('app_id'), $this->app['config']->get('token'), $this->app['config']->get('aes_key'));
|
|
|
|
return $message = $encryptor->decrypt(
|
|
$message['Encrypt'],
|
|
$this->app['request']->get('msg_signature'),
|
|
$this->app['request']->get('nonce'),
|
|
$this->app['request']->get('timestamp')
|
|
);
|
|
}
|
|
}
|
|
|