最后更新时间:2026-09-22 18:42:04
外部内容 API 路径位于 /api/api_content_*,使用 Authorization: Bearer 鉴权,要求管理员权限。与外部栏目 API 一样,写操作会写入事件日志。
GET /api/api_content_list?current=1&size=10
Authorization: Bearer YOUR_USER_TOKENcurrent:页码。size:每页数量。id、id_gt、id_lt:按 ID 查询或范围查询。title:标题筛选。slug:Slug 筛选。column_id:栏目 ID 筛选。status:状态筛选。tags:标签筛选。order:排序方式。curl -G "http://127.0.0.1:8000/api/api_content_list" \
-H "Authorization: Bearer YOUR_USER_TOKEN" \
--data-urlencode "current=1" \
--data-urlencode "size=10" \
--data-urlencode "title=关键字"GET /api/api_content_get?id=1
Authorization: Bearer YOUR_USER_TOKENcurl "http://127.0.0.1:8000/api/api_content_get?id=1" \
-H "Authorization: Bearer YOUR_USER_TOKEN"POST /api/api_content_post
Content-Type: application/json
Authorization: Bearer YOUR_USER_TOKEN外部入库接口要求 column_name,后端会按栏目名称查找栏目;栏目不存在时会自动创建栏目。因此不需要传 column_id。
{
"column_name": "产品栏目",
"name": "文章名称",
"title": "外部文章标题",
"origin": "外部来源",
"description": "文章摘要",
"keywords": "关键词",
"tags": "api,import",
"tag_ids": [],
"img": "",
"albums": "",
"content": "文章正文 HTML
",
"ext": "",
"price": 0,
"status": 1,
"source": 2,
"sort": 0,
"slug": "external-article",
"author": "外部系统",
"enable_reply": 2,
"password": "",
"create_time": ""
}column_name 必填。column_id,后端根据 column_name 处理。title 必填。content 可传 HTML 字符串。ext 按接口模型传入 JSON 字符串。status: 1 通常表示发布;敏感词检查可能将内容转为待审核状态。curl -X POST "http://127.0.0.1:8000/api/api_content_post" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_USER_TOKEN" \
-d '{
"column_name": "产品栏目",
"title": "外部文章标题",
"content": "文章正文
",
"status": 1,
"tags": "api,import"
}'成功返回新建内容的 ID:
{
"code": 200,
"msg": "ok",
"data": {
"id": 12
}
}POST /api/api_content_update
Content-Type: application/json
Authorization: Bearer YOUR_USER_TOKEN{
"id": 1,
"title": "更新后的标题",
"description": "更新后的摘要",
"content": "更新后的正文
",
"column_id": 1,
"status": 1,
"tags": "updated"
}POST /api/api_content_delete
Content-Type: application/json
Authorization: Bearer YOUR_USER_TOKEN{
"id": 1
}