服务计算第九周作业:博客网站API设计

服务计算第九周作业:博客网站API设计

作业要求

规范:REST API 设计 Github API v3 overview微软
作业:模仿 Github,设计一个博客网站的 API

API设计

查看网站主页 GET “https://myblog”

  • Request

    • Header

      Authorization: token
      
  • Response 200( application/json )

    {
          "ok": true,
          "data": ""
    }
    

当前用户 GET “https://myblog/user”

  • Request

    • Header

      Authorization: token
      
  • Response 200( application/json )

    {
        "ok": true,
        "data": {
            "id": "用户ID",
            "name": "用户",
        }
    }
    

用户身份验证 POST https://myblog.com/settings/connections/applications{/client_id}

发布文章 POST https://myblog/blog_edit

  • Request

    • Header

      Authorization: token
      
    • Body

       {
           "name": "文章名",
           "body": "文章内容"
       }
      
  • Response 200( application/json )

    {
        "ok": true,
        "data": ""
    }
    

查看用户主页 GET https://myblog/users/{username}

  • Request

    • Header

      Authorization: token
      
  • Response 200( application/json )

    {
          "ok": true,
          "data": [
              {
                  "id": 1,
                  "name": "文章名",
                  "link": "博客地址"
              }
          ]
    }
    
    

查看用户博客列表 GET https://myblog/users/{username}/blogs

  • Request

    • Header

      Authorization: token
      
      
  • Response 200( application/json )

    {
          "ok": true,
          "data": [
              {
                  "id": 1,
                  "name": "文章名",
                  "link": "博客地址"
              }
          ]
    }
    
    

查看用户个人信息 GET https://myblog/users/{username}/profile

  • Request

    • Header

      Authorization: token
      
      
  • Response 200( application/json )

    {
          "ok": true,
          "data": {
              "id": "用户ID",
              "name": "用户名",
              "...": "..."
          }
    }
    
    

查看用户粉丝列表 GET https://myblog/users/{username}/fans

  • Request

    • Header

      Authorization: token
      
      
  • Response 200( application/json )

    {
        "ok": true,
        "data": [
            {
                "name": "用户",
            }
        ]
    }
    
    

查看用户关注列表 GET https://myblog/users/{username}/followers

  • Request

    • Header

      Authorization: token
      
      
  • Response 200( application/json )

    {
        "ok": true,
        "data": [
            {
                "name": "用户名"
            }
        ]
    }
    
    

关注用户 POST https://myblog/users/{username}/following

  • Request

    • Header

      Authorization: token
      
      
  • Response 200( application/json )

    {
        "ok": true,
        "data": ""
    }
    
    

查看博客 GET https://myblog/blogs/{blogID}

  • Request

    • Header

      Authorization: token
      
      
  • Response 200( application/json )

    {
        "ok": true,
        "data": {
            "name": "文章名",
            "link": "博客地址"
        }
    }
    
    

查看评论 GET https://myblog/blogs/{blogID}/comments

  • Request

    • Header

      Authorization: token
      
      
  • Response 200( application/json )

    {
        "ok": true,
        "data": {
            "id": 1,
            "name": "文章名",
            "link": "博客地址"
        }
    }
    

发表评论 POST https://myblog/blogs/{blogID}/comments

  • Request

    • Header

      Authorization: token
      
    • Body

      {
      	"comment""评论内容"
      }
      
  • Response 200( application/json )

    {
        "ok": true,
        "data": ""
    }
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值