更新 README 文档,替换为 GeneAgro CMS 使用说明
This commit is contained in:
40
doc/API.md
Normal file
40
doc/API.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# GeneAgro CMS API 使用与认证说明
|
||||
|
||||
开启与配置
|
||||
- 后台系统配置页提供 WebAPI 设置:
|
||||
- api_open:是否开启接口能力;
|
||||
- api_auth:是否开启签名认证(建议开启);
|
||||
- api_appid:接口用户名;
|
||||
- api_secret:接口密钥。
|
||||
|
||||
认证机制
|
||||
- 时间戳与签名:
|
||||
- 传参:appid、timestamp、sign;
|
||||
- 有效期:timestamp 在 15 秒内有效;
|
||||
- 生成:sign = md5( md5( appid + secret + timestamp ) );
|
||||
- 当 api_auth=1 且校验失败时,接口拒绝访问。
|
||||
- 示例(PHP 生成签名):
|
||||
```php
|
||||
$appid = 'YOUR_APPID';
|
||||
$secret = 'YOUR_SECRET';
|
||||
$ts = time();
|
||||
$sign = md5(md5($appid . $secret . $ts));
|
||||
$url = "https://your-domain/api/list?appid={$appid}×tamp={$ts}&sign={$sign}";
|
||||
```
|
||||
|
||||
内置接口(apps/common/route.php)
|
||||
- list:内容列表;
|
||||
- content:单条内容;
|
||||
- about:关于信息;
|
||||
- search:内容搜索;
|
||||
- 具体字段取决于模型层实现,实际项目可扩展 apps/api 以提供自定义数据结构。
|
||||
|
||||
调用建议
|
||||
- 使用 HTTPS;
|
||||
- 发起端与服务端时间同步;
|
||||
- 控制速率与并发,对搜索与列表类接口做分页与缓存(如 Memcache)。
|
||||
|
||||
错误与排查
|
||||
- 403/认证失败:检查 appid/secret 与签名算法,确认时间戳是否过期;
|
||||
- 404/路由不存在:检查 apps/common/route.php 与 config/route.php 是否定义;
|
||||
- 500/内部错误:查看 log/ 文本日志或 ay_syslog 数据库日志,定位模型/控制器异常。
|
||||
Reference in New Issue
Block a user