纯 plight 平台对外接口文档(不含物理实验室平台 API)
Base URL: https://plightweb.cn/index.php?r=plight 平台提供基于 JSON 的 HTTP API。除特殊说明外,所有接口使用 POST 方法、Content-Type: application/json。
| 项 | 说明 |
|---|---|
| Base URL | https://plightweb.cn/index.php?r= |
| 请求体 / 响应体 | JSON |
| 统一响应结构 | { "status":200, "message":"", "data":... } |
| 成功 | HTTP 200 且 status == 200 |
| 失败 | status 为 4xx / 403 / 5xx,message 为原因 |
| 类型 | 载体 | 适用 |
|---|---|---|
| 登录态 | 会话 Cookie PLIGHTSESS | 需登录的接口;未登录返回 401 |
| 身份验证 Key | 请求头 x-API-Key | identity_verify 专用 |
{"username":"xxx","password":"***"}
成功:{ "status":200, "data":{ "id":1, "username":"xxx", "nickname":"昵称" } }
{"username":"xxx","password":"***","email":"可选"}
用户名 3–32 位,密码 ≥6 位;注册后自动登录,返回 data:{id},赠 +50 灯泡 +20 经验。
{ "board_id":1, "title":"标题", "content":"<HTML>", "tag":"可选标签" }
返回 data:{id, status};status=1 已公开,0 待审核。需资格的板块要授权。
{ "action":"update_info", "nickname":"", "signature":"", "bio":"", "avatar":"https://", "cover":"https://" }
{ "action":"update_pass", "email":"", "password":"***" }
{ "action":"update_medals", "medal_ids":[1,2,3] }
{ "action":"create", "post_id":123, "content":"评论内容" } // 发表
{ "action":"delete", "id":评论ID } // 删除(作者/楼主/管理员)
{ "post_id":123, "amount":1 }
amount=1 点赞(再点取消);amount>1 为打赏。返回 data:{starred:true|false}。
{ "action":"list", "category":0 } // 0全部 1管理 2通知 3用户通知 4关注通知
{ "action":"read", "id":消息ID }
{ "action":"read_all" }
{ "action":"send", "to_id":用户ID, "content":"内容" }
站内信 30 天自动清理。
{ "action":"list" } // 勋章列表
{ "action":"grant", "user_id":1, "medal_id":2 }
{ "action":"auto" }
{ "action":"list" }
{ "action":"solve", "id":反馈ID }
{ "action":"list" }
{ "action":"add", "user_id":1, "perm":"wenxuan" }
{ "action":"remove", "id":授权ID }
{}
每日首次 +10 灯泡 +20 经验;当日重复返回 data:{done:true, gold}。
x-API-Key(在官网后台配置)。{ "mode":"verify", "username":"xxx", "password":"***" }
{ "mode":"token", "token":"***" }
{ "mode":"lookup", "username":"xxx" } // 也可用 uid / 平台用户ID
以上三种模式返回 data:
{ "uid":"", "username":"", "nickname":"", "role":0, "status":1,
"is_wushi":1, "wushi_name":"", "wushi_id":"", "level":1, "gold":0,
"verify_token":"仅 verify 模式返回,5 分钟有效" }
// 帖子
{ "action":"post_review_list" }
{ "action":"post_review", "id":帖子ID, "result":1 } // 1通过 2驳回
{ "action":"post_delete", "id":帖子ID }
{ "action":"post_feature", "id":帖子ID }
{ "action":"post_sticky", "id":帖子ID, "value":1 }
// 成员
{ "action":"users", "q":"搜索词" }
{ "action":"user_update", "id":1, "role":2, "email":"", "nickname":"", "password":"" }
{ "action":"user_ban", "id":1, "mode":3, "days":7 } // 2临时禁言 3封禁
{ "action":"user_unban", "id":1 }
// 组织 / 勋章 / 公告 / 站内信
{ "action":"org_list" }
{ "action":"org_create", "name":"组织名", "intro":"简介" }
{ "action":"medal_create", "name":"勋章名", "tier":2, "image":"", "desc":"" }
{ "action":"ann_add", "title":"公告", "content":"", "link":"" }
{ "action":"send_message", "to_id":1, "title":"", "content":"" }
| status | 含义 |
|---|---|
| 400 | 请求字段缺失或格式错误 |
| 401 | 未登录 / API Key 无效 / token 无效 |
| 403 | 权限不足 / 板块无资格 / 账号封禁 |
| 404 | 内容或用户不存在 |
| 409 | 用户名已占用 |
# 登录
curl -k -X POST "https://plightweb.cn/index.php?r=api/login" \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"***"}'
# 身份快捷验证
curl -k -X POST "https://plightweb.cn/index.php?r=api/identity_verify" \
-H "Content-Type: application/json" -H "x-API-Key: ***" \
-d '{"mode":"verify","username":"xxx","password":"***"}'
app/config.php 中把 app.debug 设为 false,并修改 app.url(plightweb.cn)、app.verify_key、wushi.secret。