From 2cce1b6201d0000938a9cd2fb51af5b36d0171f5 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Tue, 8 Jul 2025 21:12:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E5=8D=8F=E8=AE=AE=E4=B8=BAhttp=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0API=E6=A0=B9=E8=B7=AF=E5=BE=84=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复开发者注册邮件验证链接错误使用https协议的问题,改为使用http协议 在API入口添加根路径处理,返回可用端点信息和示例 添加数据库查询错误处理,返回500状态码和错误信息 --- api.php | 23 +++++++++++++++++++++++ developer/register.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/api.php b/api.php index a938900..1882fe1 100644 --- a/api.php +++ b/api.php @@ -4,6 +4,24 @@ header('Content-Type: application/json'); $requestMethod = $_SERVER['REQUEST_METHOD']; +// API根路径处理 - 返回可用端点信息 +if (!isset($_GET['action'])) { + http_response_code(200); + echo json_encode([ + 'status' => 'success', + 'message' => 'App Store API', + 'version' => '1.0', + 'endpoints' => [ + '/api?action=list' => '获取应用列表,支持search、platform、age_rating、tag、page、limit参数', + '/api?action=app&id=1' => '获取指定ID的应用详情', + '/api?action=favorite' => '收藏应用(POST方法,需app_id和user_id参数)' + ], + 'example' => 'GET /api?action=list&platform=windows&limit=20' + ]); + exit; +} + + // 支持查询参数路由模式(不依赖URL重写) if (isset($_GET['action'])) { $action = $_GET['action']; @@ -85,6 +103,11 @@ if (isset($_GET['action'])) { // 执行主查询 $stmt = $conn->prepare($sql); + if (!$stmt) { + http_response_code(500); + echo json_encode(['error' => 'Database error: ' . $conn->error]); + exit; + } call_user_func_array([$stmt, 'bind_param'], array_merge([$paramTypes], $stmtParams)); $stmt->execute(); $result = $stmt->get_result(); diff --git a/developer/register.php b/developer/register.php index 235e84c..50c8049 100644 --- a/developer/register.php +++ b/developer/register.php @@ -98,7 +98,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $error = '系统错误,请稍后再试'; } else { // 生成验证链接 - $verificationLink = 'https://' . $_SERVER['HTTP_HOST'] . '/developer/verify_email.php?token=' . urlencode($verificationToken); + $verificationLink = 'http://' . $_SERVER['HTTP_HOST'] . '/developer/verify_email.php?token=' . urlencode($verificationToken); // 加载邮件模板 $templatePath = __DIR__ . '/../mail/verification_template.php';