You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
721 B
31 lines
721 B
<?php
|
|
|
|
namespace app\controller\wechat;
|
|
|
|
|
|
use app\service\wechat\WechatService;
|
|
use think\Request;
|
|
class Wechat extends Base
|
|
{
|
|
|
|
public function index(Request $request)
|
|
{
|
|
|
|
$param = $request->param();
|
|
|
|
$signature = $param['signature'] ?? '';// 签名
|
|
$timestamp = $param['timestamp'] ?? '';// 时间戳
|
|
$nonce = $param['nonce'] ?? '';// 随机数
|
|
$echostr = $param['echostr'] ?? '0'; // 随机字符串
|
|
|
|
$checkRes = (new WechatService())->wechatChekToken($signature,$timestamp,$nonce);
|
|
|
|
$param['res_error'] = $checkRes;
|
|
|
|
if ($checkRes) {
|
|
echo $echostr;die;
|
|
}
|
|
|
|
return $this->buildFailed(400,'微信认证失败!');
|
|
}
|
|
}
|