API接口
SoeayCMS 提供 RESTful API 接口,支持前后端分离开发。
接口列表
| 接口 | 方法 | 说明 |
|---|---|---|
| /api/content/list | GET | 获取内容列表 |
| /api/content/detail | GET | 获取内容详情 |
| /api/sort/list | GET | 获取栏目列表 |
| /api/sort/detail | GET | 获取栏目详情 |
| /api/search | GET | 搜索内容 |
| /api/member/login | POST | 会员登录 |
| /api/member/register | POST | 会员注册 |
| /api/message | POST | 提交留言 |
| /api/comment | POST | 发表评论 |
内容列表接口
GET /api/content/list?scode=2&num=10&page=1
Response:
{
"code": 200,
"data": {
"list": [
{
"id": 1,
"title": "文章标题",
"url": "/news/1.html",
"date": "2025-01-01"
}
],
"total": 100,
"page": 1,
"pagesize": 10
}
}
内容详情接口
GET /api/content/detail?id=10
Response:
{
"code": 200,
"data": {
"id": 10,
"title": "文章标题",
"content": "<p>文章内容...</p>",
"keywords": "关键词",
"description": "描述",
"visits": 123
}
}
跨域配置
在 config/app.php 中配置允许的域名:
'cors' => [
'allowed_origins' => [
'http://localhost:3000',
'https://www.soeaycms.com',
],
],
