设计一个博客网站的API

设计一个博客网站的API

设计格式:
·协议为: HTTPS
·博客根地址为:https://myblog.com
·所有数据以JSON形式发送和接收

认证方式:
基本认证

curl -u username https://myblog.com

通过输入用户名,然后再进行输入密码进行认证。需要身份验证的请求在某些地方将返回404 Not Found,而不是 403 Forbidden。这是为了防止私有存储库意外泄露给未经授权的用户。

访问指定用户的所有文章

curl -i -u https://myblog.com/user/articles
{
 "articles_num": 32,
 "its": [
  {
    "A_name": "name",
    "A_id": 5201314,
    "A_words": 52000
    "A_publishtime": "2019/22/1",
    "language": Chinese,
    "A_contents": "xxx"
    "author": {
      "P_name": "SS",
      "P_id": 520,
      "P_sex": female
    }
  },
 ]
}

筛选指定文章

curl -u -i https://myblog.com/user/articles/id=2
{
    "exit": true,
    "article":{
     "id": 2,
     "A_name": "xxx",
     "A_publishtime": "2019/22/1",
     "subscribetime": 4246,
     "A_words": 63845,
     "language": Chinese,
     "A_contents": "xxx"
     "author": {
       "P_name": SS,
       "P_id": 1213,
       "p_sex": female
     }
  }
}

发布文章

curl -u -i -d '{"title":"...", "id":"...", "content":"xxx"}'
https://myblog.com/user/pub/article
{
  "status": true,
  "article":{
     "id": 520,
     "A_name": "xxx",
     "A_publishtime": "2019/22/1",
     "subscribetime": 4246,
     "A_words": 63845,
     "A_contents": "xxx",
     "language": Chinese,
     "author": {
       "P_name": SS,
       "P_id": 1213,
       "p_sex": female
     }
  }
}

删除文章

curl -i -u https://myblog.com/user/del/article/id=2
{
   "check_id": 2,
    "status_del": true
}

你可能感兴趣的:(设计一个博客网站的API)