代码用PHP编写,采用Laravel框架
git clone https://github.com/greennyreborn/forum_demo.git
cd forum_demo
composer install
采用 nginx + php-fpm 部署
- Create user
{
method: 'POST',
url: '/user',
params: {
"username": "test",
"avatar": "",
"password": "12345678"
}
}
- Create Topic
{
method: 'POST',
url: '/topic/user/{uid}',
params: {
"title": "hello",
"type": "1",
"content": "test"
}
}
- Edit Topic
{
method: 'PUT',
url: '/topic/{topic_id}',
params: {
"title": "hello",
"type": "1",
"content": "test"
}
}
- Create Post
{
method: 'POST',
url: '/post/topic/{topic_id}',
params: {
"uid": "4164485977",
"content": "啦啦啦"
}
}
- Edit Post
{
method: 'PUT',
url: '/post/{post_id}',
params: {
"content": "啦啦啦"
}
}
- Show topic list
{
method: 'GET',
url: '/topic/list?offset=0&size=20',
}
- Show topic detail
{
method: 'GET',
url: '/topic/{topic_id}?offset=0&size=20',
}
脚本用python编写
需要 mysql-connector 和 requests 模块
- 创建用户
python scripts/create_user.py
- 创建 Topic & Post
python scripts/api_test.py