服務計算第九周作業:博客網站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": "" }