MSPH API 文档
本文档用于通过 API Key 远程管理 MSPH 文章(创建 / 更新 / 删除 / 上传图片与封面)。
认证方式
- Header: X-API-Key: <你的 key>
- 或 Authorization: Bearer <你的 key>
上传图片 / 封面
POST /api/ph/v1/upload
Form: file (multipart)
响应字段:
- attachment_path: 例如 ph/xxxx.webp
- attachment_type / media_type
Markdown 中引用图片:
创建文章
POST /api/ph/v1/article
JSON:
{
"slug": "optional-slug",
"title": "标题",
"content_md": "内容",
"is_public": true,
"cover_path": "ph/xxx.webp",
"tags": "a,b,c",
"summary": "摘要"
}
更新文章
PUT /api/ph/v1/article/{slug}
JSON:
{
"title": "标题",
"content_md": "内容",
"is_public": true,
"cover_path": "ph/xxx.webp",
"tags": "a,b,c",
"summary": "摘要"
}
获取文章
GET /api/ph/v1/article/{slug}
删除文章
DELETE /api/ph/v1/article/{slug}
使用示例
curl -X POST "https://你的域名/api/ph/v1/upload" \
-H "X-API-Key: YOUR_KEY" \
-F "file=@cover.png"
curl -X POST "https://你的域名/api/ph/v1/article" \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"API 文档","content_md":"hello","is_public":true}'