设计一个博客网站的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
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值