安全检测

This commit is contained in:
2025-12-26 15:48:01 +08:00
parent 7182a92dd0
commit 00c4843b8b
3 changed files with 182 additions and 0 deletions
+14
View File
@@ -4,6 +4,7 @@ namespace app\common\service;
use app\common\model\MessageNotice;
use app\common\model\Post;
use app\common\model\User;
use app\common\validate\PostCommentValidate;
use app\common\traits\crud\CrudServiceTrait;
use app\common\model\PostComment;
@@ -109,6 +110,19 @@ class PostCommentService
}
}
//安全检查
$wechat = new WechatService();
$tokenData = $wechat->getMiniAccessToken();
$access_token = $tokenData['access_token'];
$user = User::where('id', $request->user->uid)->first();
if(empty($user)){
throw new \Exception('用户不存在');
}
$tokenData = $wechat->checkText($data['content'], $user['openid'], $access_token, 2);
// $tokenData = $wechat->checkText($data['content'], 'o4Y7y4rN5Gui_JhaBm3NMBl_eqB4', $access_token, 2);
return $data;
}