评论安全验证

This commit is contained in:
2025-12-26 16:20:46 +08:00
parent 986066017c
commit 39683578ba
2 changed files with 168 additions and 0 deletions
+15
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;
@@ -114,6 +115,20 @@ 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'], 'o8W4t5cRtq2LuOJUxvBGWQA6HJKQ', $access_token, 2);
return $data;
}