社區(qū)服務(wù) API 接口文檔
基礎(chǔ)相關(guān)信息
-
服務(wù)器請求地址:http://ts.lagou.uieee.com
客戶端訪問統(tǒng)一接口規(guī)則 :
/api/v2/
gitHub 完整 API 接口服務(wù)文檔查閱:https://github.com/slimkit/slimkit.github.io/tree/gh-pages/docs
-
體驗(yàn)版前臺(tái)地址:http://ts.lagou.uieee.com/feeds
-
后臺(tái)管理系統(tǒng)地址: http://ts.lagou.uieee.com/admin
體驗(yàn)賬號(hào):root
登陸密碼:root
一、廣告管理
1.1 查詢所有廣告位
GET /advertisingspace
Status: 200 OK
[
{
"id": 1,
"channel": "boot", // 廣告位所屬模塊
"space": "boot", // 廣告位標(biāo)識(shí)
"alias": "啟動(dòng)圖廣告", // 廣告位別名
"allow_type": "image", // 廣告位允許的廣告類型
"format": { // 廣告數(shù)據(jù)格式
"image": {
"image": "圖片|string|表單描述",
"link": "鏈接|string|表單描述"
}
},
"created_at": "2017-07-27 06:56:36",
"updated_at": "2017-07-27 06:56:36"
},
// 更多......
]
1.2 獲取一個(gè)廣告位的廣告列表
// space 代表 廣告位 ID 參數(shù)信息
GET /advertisingspace/:space/advertising
Status: 200 OK
[
{
"id": 1,
"space_id": 1, // 廣告位id
"title": "廣告1", // 廣告標(biāo)題
"type": "image", // 廣告類型
"data": { // 廣告數(shù)據(jù)
"image": "http://plus.bai/api/v2/files/1", // 廣告圖片地址
"link": "http://www.baidu.com" // 廣告鏈接
},
"sort": 2,
"created_at": "2017-07-27 15:09:15",
"updated_at": "2017-07-27 15:09:16"
}
]
1.3 批量獲取廣告列表
GET /advertisingspace/advertising?space=1,2,3
名稱 | 類型 | 描述 |
---|---|---|
space | 字符串 | 廣告位id,多個(gè)以逗號(hào)隔開 |
Status: 200 OK
[
{
"id": 1,
"space_id": 1, // 廣告位id
"title": "廣告1", // 廣告標(biāo)題
"type": "image", // 廣告類型
"data": { // 廣告數(shù)據(jù)
"image": "http://plus.bai/api/v2/files/1", // 廣告圖片地址
"link": "http://www.baidu.com" // 廣告鏈接
},
"sort": 2,
"created_at": "2017-07-27 15:09:15",
"updated_at": "2017-07-27 15:09:16"
}
]
二、動(dòng)態(tài)管理
2.1 批量獲取動(dòng)態(tài)列表信息
GET /feeds
名稱 | 類型 | 描述 |
---|---|---|
limit | Integer | 可選,默認(rèn)值 20 ,獲取條數(shù) |
after | Integer | 可選,上次獲取到數(shù)據(jù)最后一條 ID,用于獲取該 ID 之后的數(shù)據(jù)。 |
type | String | 可選,默認(rèn)值 new,可選值 new 、hot 、 follow 、users
|
search | String | type = new 時(shí)可選,搜索關(guān)鍵字 |
user | Integer | type = users 時(shí)可選,默認(rèn)值為當(dāng)前用戶id |
screen | string | type = users 時(shí)可選,paid -付費(fèi)動(dòng)態(tài) pinned - 置頂動(dòng)態(tài) |
id |
integer or string
|
可選,按照動(dòng)態(tài) ID 獲取動(dòng)態(tài)列表。 |
hot |
integer |
可選,僅 type=hot 時(shí)有效,用于熱門數(shù)據(jù)翻頁標(biāo)記!上次獲取數(shù)據(jù)最后一條的 hot 值 |
{
"ad": null,
"pinned": [...], // 置頂動(dòng)態(tài)列表
"feeds": [
{
"id": 1,
"user_id": 1,
"feed_content": "12312312312",
"feed_from": 1,
"like_count": 0,
"feed_view_count": 4,
"feed_comment_count": 3,
"feed_latitude": "",
"feed_longtitude": "",
"feed_geohash": "",
"audit_status": 1,
"feed_mark": 12312312,
"pinned": 1,
"pinned_amount": 0,
"created_at": "2017-08-01 16:46:19",
"updated_at": "2017-08-05 03:29:55",
"deleted_at": null,
"comments": [
{
"id": 4,
"user_id": 1,
"target_user": 1,
"reply_user": 0,
"body": "辣雞啊啊啊啊",
"commentable_id": 1,
"commentable_type": "feeds",
"created_at": "2017-08-05 03:29:55",
"updated_at": "2017-08-05 03:29:55",
"pinned": true
}
],
"has_collect": false,
"has_like": false,
"images": [],
"paid_node": null,
"topics": [ // 話題數(shù)據(jù)
{
"id": 1, // 話題 ID
"name": "第一個(gè)話題" // 話題名稱
}
]
}
]
}
名稱 | 類型 | 描述 |
---|---|---|
id | int | 動(dòng)態(tài)數(shù)據(jù)id |
user_id | int | 發(fā)布者id |
feed_content | string | 動(dòng)態(tài)內(nèi)容 |
feed_from | int | 動(dòng)態(tài)來源 1:pc 2:h5 3:ios 4:android 5:其他 |
like_count | int | 點(diǎn)贊數(shù) |
feed_view_count | int | 查看數(shù) |
feed_comment_count | int | 評論數(shù) |
feed_latitude | string | 緯度 |
feed_longtitude | string | 經(jīng)度 |
feed_geohash | string | GEO |
audit_status | int | 審核狀態(tài) |
feed_mark | int | 標(biāo)記 |
pinned | int | 置頂標(biāo)記 |
pinned_amount | int | 置頂金額 |
comments | array | 動(dòng)態(tài)評論 列表中返回五條 |
comments.id | int | 評論id |
comments.user_id | int | 評論者id |
comments.target_user | int | 資源作者id |
comments.reply_user | int | 被回復(fù)者id |
comments.body | string | 評論內(nèi)容 |
comments.pinned | bool | 評論置頂標(biāo)記 不存在則為普通評論 |
has_collect | bool | 是否已收藏 |
has_like | bool | 是否已贊 |
images | array | 圖片信息 同單條動(dòng)態(tài)數(shù)據(jù)結(jié)構(gòu)一致 |
paid_node | array | 付費(fèi)節(jié)點(diǎn)信息 同單條動(dòng)態(tài)數(shù)據(jù)結(jié)構(gòu)一致 不存在時(shí)為null |
topics |
Array |
參考「動(dòng)態(tài)詳情」,內(nèi)容一致。 |
2.2 獲取指定 ID 動(dòng)態(tài)詳情
GET /feeds/:feed
{
"id": 13,
"created_at": "2017-06-21 01:54:52",
"updated_at": "2017-06-21 01:54:52",
"deleted_at": null,
"user_id": 1, // 發(fā)布動(dòng)態(tài)的用戶
"feed_content": "動(dòng)態(tài)內(nèi)容", // 內(nèi)容
"feed_from": 2,
"like_count": 0, // 點(diǎn)贊數(shù)
"feed_view_count": 0, // 查看數(shù)
"feed_comment_count": 0, // 評論數(shù)
"feed_latitude": null, // 緯度
"feed_longtitude": null, // 經(jīng)度
"feed_geohash": null, // GeoHash
"audit_status": 1, // 審核狀態(tài)
"feed_mark": 12,
"has_like": true, // 是否點(diǎn)贊
"has_collect": false, // 用戶是否收藏當(dāng)前動(dòng)態(tài)
"paid_node": {
"paid": true, // 當(dāng)前用戶是否已經(jīng)付費(fèi)
"node": 9, // 付費(fèi)節(jié)點(diǎn)
"amount": 20 // 付費(fèi)金額
},
"comment_paid_node": { // 評論收費(fèi)信息.
"paid": true,
"node": 11,
"amount": 50
},
"reward": {
"count": 3, // 被打賞次數(shù)
"amount": "600" // 被打賞總金額
},
"images": [ // 圖片
{
"file": 4, // 文件 file_with 標(biāo)識(shí) 不收費(fèi)圖片只存在 file 這一個(gè)字段。
"size": null, // 圖像尺寸,非圖片為 null,圖片沒有尺寸也為 null,
"amount": 100, // 收費(fèi)多少
"type": "download", // 收費(fèi)方式
"paid": false, // 當(dāng)前用戶是否購買
"paid_node": 10 付費(fèi)節(jié)點(diǎn)
},
{
"file": 5,
"size": '1930x1930' // 當(dāng)圖片有尺寸的時(shí)候采用 width x height 格式返回。
}
],
"likes": [
{
"id": 2,
"user_id": 1,
"target_user": 1,
"likeable_id": 1,
"likeable_type": "feeds",
"created_at": "2017-07-12 08:09:07",
"updated_at": "2017-07-12 08:09:07"
}
],
"topics": [ // 話題數(shù)據(jù)
{
"id": 1, // 話題 ID
"name": "第一個(gè)話題" // 話題名稱
}
],
"repostable_type": null, // 轉(zhuǎn)發(fā)資源類型
"repostable_id": null, // 轉(zhuǎn)發(fā)資源 ID
}
2.3 創(chuàng)建一條動(dòng)態(tài)
POST /feeds
Name | Type | Description |
---|---|---|
feed_content | string | 分享內(nèi)容。如果存在附件,則為可選,否則必須存在 |
feed_from | integer | 客戶端標(biāo)識(shí),1-PC、2-Wap、3-iOS、4-android、5-其他 |
feed_mark | mixed | 客戶端請求唯一標(biāo)識(shí) |
feed_latitude | string | 緯度,當(dāng)經(jīng)度, GeoHash 任意一個(gè)存在,則本字段必須存在 |
feed_longtitude | string | 經(jīng)度,當(dāng)緯度, GeoHash 任意一個(gè)存在,則本字段必須存在 |
feed_geohash | string | GeoHash,當(dāng)緯度、經(jīng)度 任意一個(gè)存在,則本字段必須存在 |
amount | inteter | 動(dòng)態(tài)收費(fèi),不存在表示不收費(fèi),存在表示收費(fèi)。 |
images | array | 結(jié)構(gòu):{ id: <id>, amount: <amount>, type: <read,download> } ,amount 為可選,id 必須存在,amount 為收費(fèi)金額,單位分, type 為收費(fèi)方式
|
topics |
Array |
可選,需要關(guān)聯(lián)的話題 ID 數(shù)組。 |
topics.* |
integer |
如果 topics 存在則必須,話題 ID。 |
repostable_type |
string |
可選,如果 repostable_id 存在則必須,轉(zhuǎn)發(fā)資源類型標(biāo)識(shí)。 |
repostable_id |
integer |
可選,如果 repostable_type 存在則必須,轉(zhuǎn)發(fā)資源 ID。 |
{
"feed_content": "內(nèi)容",
"feed_from": "5",
"feed_mark": "xxxxx1",
"images": [
{
"id": 1
},
{
"id": 1
"amount": 100,
"type": "read"
}
],
"feed_latitude": "12.32132123",
"feed_longtitude": "32.33332123",
"feed_geohash": "GdUDHyfghjd==",
"amount": 450,
"topics": [1, 2, 3]
}
Status: 201 Created
{
"message": [
"發(fā)布成功"
],
"id": 1
}
2.4 點(diǎn)贊、取消點(diǎn)贊、點(diǎn)贊列表 當(dāng)前動(dòng)態(tài)
點(diǎn)贊
POST /feeds/:feed/like
Status: 201 Created
{
"message": [
"操作成功"
]
}
取消點(diǎn)贊
DELETE /feeds/:feed/unlike
Status: 204 Not Content
點(diǎn)贊人列表
GET /feeds/:feed/likes
名稱 | 類型 | 描述 |
---|---|---|
limit | Integer | 獲取條數(shù),默認(rèn) 20 |
after | Integer |
id 獲取之后數(shù)據(jù),默認(rèn) 0 |
Status: 200 OK
[
{
"id": 3,
"user_id": 2,
"target_user": 1,
"likeable_id": 1,
"likeable_type": "feeds",
"created_at": "2017-07-12 08:09:07",
"updated_at": null,
"user": {
"id": 2,
"name": "test1",
"bio": "0",
"sex": 0,
"location": "0",
"created_at": "2017-06-12 07:38:55",
"updated_at": "2017-06-12 07:38:55",
"following": true,
"follower": false,
"avatar": null,
"bg": null,
"verified": null,
"extra": null
}
}
]
字段 | 描述 |
---|---|
id | 喜歡 ID |
user_id | 點(diǎn)喜歡用戶 ID |
target_user | 接收喜歡用戶 ID |
likeable_id | 喜歡的資源 ID,配置 likeable_type 表示不同資源 |
likeable_type | 喜歡的資源類型。 |
created_at | 點(diǎn)喜歡時(shí)間 |
updated_at | 更新時(shí)間 |
user | 點(diǎn)喜歡的用戶資料,結(jié)構(gòu)參考 「用戶信息」接口說明。 |
2.5 評論指定 ID 動(dòng)態(tài)
發(fā)布一條評論
POST /feeds/:feed/comments
Name | Type | Description |
---|---|---|
body | String | 評論內(nèi)容 |
reply_user | Integer | 評論用戶 ID |
Status: 201 Created
{
"message": [
"操作成功"
],
"comment": {
"user_id": 1,
"reply_user": 0,
"target_user": 1,
"body": "我是第三條評論",
"commentable_type": "feeds",
"commentable_id": 1,
"updated_at": "2017-07-20 08:53:24",
"created_at": "2017-07-20 08:53:24",
"id": 3
}
}
獲取當(dāng)前動(dòng)態(tài)所有評論
GET /feeds/:feed/comments
Name | Type | Description |
---|---|---|
limit | Integer | 單次請求條數(shù),默認(rèn)為20 |
after | Integer | 最后一條評論的 ID 用來做請求區(qū)分 |
Status: 200 OK
{
"pinneds": [
{
"id": 2,
"user_id": 1,
"target_user": 1,
"reply_user": 0,
"body": "我是第一條評論",
"commentable_id": 1,
"commentable_type": "feeds",
"created_at": "2017-07-20 08:35:18",
"updated_at": "2017-07-20 08:35:18"
}
],
"comments": [
{
"id": 3,
"user_id": 1,
"target_user": 1,
"reply_user": 0,
"body": "我是第三條評論",
"commentable_id": 1,
"commentable_type": "feeds",
"created_at": "2017-07-20 08:53:24",
"updated_at": "2017-07-20 08:53:24"
}
]
}
Name | Description |
---|---|
pinneds | Pinned comments list. |
comment | Comments list. |
*.id | The ID of the comment. |
*.user_id | Commentator. |
*.target_user | Own dynamic publisher. |
*.reply_user | Reverted to the user. |
*.body | The body of the comment. |
*.commentable_id | Feeds id. |
*.commentable_type | Commentable type. |
*.created_at | Comment release time. |
*.updated_at | Comment update time. |
獲取當(dāng)前一條評論的詳細(xì)信息
GET /feeds/:feed/comments/:comment
Status: 200 OK
{
"id": 1,
"user_id": 1,
"target_user": 1,
"reply_user": 0,
"body": "我是第一條評論",
"commentable_id": 1,
"commentable_type": "feeds",
"created_at": "2017-07-20 08:34:41",
"updated_at": "2017-07-20 08:34:41"
}
Name | Description |
---|---|
id | The ID of the comment. |
user_id | Commentator. |
target_user | Own dynamic publisher. |
reply_user | Reverted to the user. |
body | The body of the comment. |
commentable_id | Feeds id. |
commentable_type | Commentable type. |
created_at | Comment release time. |
updated_at | Comment update time. |
刪除一條評論
DELETE /feeds/:feed/comments/:comment
Status: 204 No Content
2.6 刪除指定 ID動(dòng)態(tài)
DELETE /feeds/:feed/currency
2.7 收藏、取消收藏當(dāng)前動(dòng)態(tài)
收藏
POST /feeds/:feed/collections
Status: 201 Created
{
"message": [
"收藏成功"
]
}
取消收藏
DELETE /feeds/:feed/uncollect
Status: 204 No Centent
收藏列表
GET /feeds/collections
名稱 | 類型 | 描述 |
---|---|---|
limit | Integer | 可選,默認(rèn)值 20 ,獲取條數(shù) |
offset | Integer | 可選,偏移量,用于翻頁,傳入已請求過的數(shù)據(jù)總數(shù) |
user | Integer | type = users 時(shí)可選,默認(rèn)值為當(dāng)前用戶id |
Status: 200 OK
[
{...} // 數(shù)據(jù)參考動(dòng)態(tài)單條內(nèi)容
]
2.8 舉報(bào)一個(gè)動(dòng)態(tài)
POST /feeds/:feed/reports
名稱 | 描述 |
---|---|
reason | 舉報(bào)理由 |
Http Status 201
{
"message": [
"操作成功"
]
}
三、資訊管理
3.1 批量獲取資訊列表信息
GET /news
名稱 | 說明 |
---|---|
limit | 數(shù)據(jù)返回條數(shù) 默認(rèn)為20 |
after | 數(shù)據(jù)翻頁標(biāo)識(shí) |
key | 搜索關(guān)鍵字 |
cate_id | 分類id |
recommend | 推薦篩選 =1為篩選推薦資訊列表 |
id |
需要按照 ID 獲取的資訊 ID,多個(gè)使用半角 , 進(jìn)行分割 |
Status: 200 OK
[
{
"id": 2,
"title": "asdasdasdad",
"subject": "阿拉拉啊拉",
"created_at": "2017-08-02 03:28:38",
"updated_at": "2017-08-02 09:08:51",
"from": "原創(chuàng)",
"author": "root",
"user_id": 1,
"hits": 10,
"has_collect": false,
"has_like": false,
"category": {
"id": 1,
"name": "1121",
"rank": 0
},
"image": {
"id": 2,
"size": "370x370"
}
},
{
"id": 1,
"title": "123",
"subject": "0",
"created_at": "2017-07-31 11:56:32",
"updated_at": "2017-07-31 06:31:31",
"from": "原創(chuàng)",
"author": "root",
"user_id": 1,
"hits": 5,
"has_collect": false,
"has_like": false,
"category": {
"id": 1,
"name": "1121",
"rank": 0
},
"image": {
"id": 1,
"size": "100x100"
}
}
]
名稱 | 類型 | 說明 |
---|---|---|
id | int | 數(shù)據(jù)id |
title | string | 資訊標(biāo)題 |
subject | string | 副標(biāo)題 |
from | string | 來源 |
author | string | 作者 |
user_id | int | 發(fā)布者id |
hits | int | 點(diǎn)擊數(shù) |
has_collect | bool | 當(dāng)前用戶是否已收藏 |
has_like | bool | 當(dāng)前用戶是否已點(diǎn)贊 |
category | array | 所屬分類信息 |
category.id | int | 所屬分類id |
category.name | string | 所屬分類名稱 |
category.rank | int | 所屬分類排序 |
image | array/null | 資訊封面信息 為null時(shí)表示該資訊無縮略圖 |
image.id | int | 資訊封面附件id |
image.size | string | 資訊封面尺寸 |
3.2 獲取指定 ID 資訊詳情信息
GET /news/{news}
Status: 200 OK
{
"id": 2,
"created_at": "2017-08-02 03:28:38",
"updated_at": "2017-08-02 09:08:51",
"title": "asdasdasdad",
"content": "@ adasd image @",
"digg_count": 0,
"comment_count": 0,
"hits": 4,
"from": "原創(chuàng)",
"is_recommend": 0,
"subject": "阿拉拉啊拉",
"author": "root",
"audit_status": 0,
"audit_count": 0,
"user_id": 1,
"contribute_amount": 100,
"has_collect": false,
"has_like": false,
"is_pinned": false,
"category": {
"id": 1,
"name": "1121",
"rank": 0
},
"image": {
"id": 2,
"size": "370x370"
},
"tags": [
{
"id": 2,
"name": "標(biāo)簽2",
"tag_category_id": 1
},
{
"id": 1,
"name": "標(biāo)簽1",
"tag_category_id": 1
}
]
}
名稱 | 類型 | 說明 |
---|---|---|
id | int | 資訊id |
title | string | 標(biāo)題 |
content | text | 資訊內(nèi)容 markdown格式 含自定義標(biāo)簽() |
digg_count | int | 點(diǎn)贊數(shù) |
comment_count | int | 評論數(shù) |
hits | int | 點(diǎn)擊量 |
from | string | 來源 |
is_recommend | int | 是否為推薦 |
subject | string | 副標(biāo)題 |
author | string | 作者 |
audit_status | int | 審核狀態(tài) 0-正常 1-待審核 2-草稿 3-駁回 4-刪除 5-退款中 |
audit_count | int | 審核駁回次數(shù) |
user_id | int | 發(fā)布者id |
contribute_amount | int | 投稿金額 |
has_collect | bool | 當(dāng)前用戶是否已收藏 |
has_like | bool | 當(dāng)前用戶是否已點(diǎn)贊 |
is_pinned | bool | 是否已置頂 1-已置頂 |
category | array | 所屬分類信息 |
category.id | int | 所屬分類id |
category.name | string | 所屬分類名稱 |
category.rank | int | 所屬分類排序 |
image | array | 資訊封面信息 |
image.id | int | 資訊封面附件id |
image.size | string | 資訊封面尺寸 |
tags | array | 標(biāo)簽列表 |
tags.id | int | 標(biāo)簽id |
tags.name | string | 標(biāo)簽名稱 |
tags.tag_category_id | int | 標(biāo)簽分類id |
3.3 點(diǎn)贊、取消點(diǎn)贊、點(diǎn)贊列表當(dāng)前資訊
喜歡資訊
POST /news/{news}/likes
Status: 201 Created
取消喜歡資訊
DELETE /news/{news}/likes
Status: 204 No Content
資訊喜歡列表
GET /news/{news}/likes
Status: 200 Ok
[
{
"id": 5,
"user_id": 1,
"target_user": 1,
"likeable_id": 4,
"likeable_type": "news",
"created_at": "2017-08-08 02:25:34",
"updated_at": "2017-08-08 02:25:34",
"user": {
"id": 1,
"name": "baishi",
"bio": null,
"sex": 1,
"location": null,
"created_at": "2017-07-31 03:16:19",
"updated_at": "2017-08-09 10:09:28",
"following": false,
"follower": false,
"avatar": null,
"bg": null,
"verified": null,
"extra": {
"user_id": 1,
"likes_count": 2,
"comments_count": 9,
"followers_count": 0,
"followings_count": 0,
"updated_at": "2017-08-17 07:05:06",
"feeds_count": 0,
"questions_count": 0,
"answers_count": 19
}
}
}
]
名稱 | 類型 | 說明 |
---|---|---|
user_id | int | 喜歡用戶id |
target_user | int | 被喜歡用戶id |
likeable_id | int | 被喜歡資源id |
created_at | date | 喜歡時(shí)間 |
user | array | 用戶信息 |
3.4 評論指定 ID 資訊
評論一條資訊
POST /news/{news}/comments
名稱 | 描述 |
---|---|
body | 評論內(nèi)容 |
reply_user | 被回復(fù)用戶id 默認(rèn)為0 |
Status: 201 Created
{
"message": [
"操作成功"
],
"comment": {
"user_id": 1,
"reply_user": 0,
"target_user": 1,
"body": "baishi",
"commentable_type": "news",
"commentable_id": 2,
"updated_at": "2017-08-10 09:31:58",
"created_at": "2017-08-10 09:31:58",
"id": 5
}
}
名稱 | 描述 |
---|---|
message | 消息 |
comment | 評論信息 |
comment.id | 評論id |
comment.user_id | 評論者id |
comment.target_user | 資訊發(fā)布者id |
comment.reply_user | 被回復(fù)者id |
comment.body | 評論內(nèi)容 |
獲取一條資訊的評論列表
GET /news/{news}/comments
名稱 | 類型 | 必須 | 說明 |
---|---|---|---|
limit | int | - | 數(shù)據(jù)返回條數(shù) |
after | int | - | 數(shù)據(jù)翻頁標(biāo)識(shí) |
Status: 200 OK
{
"pinneds": [],
"comments": [
{
"id": 2389,
"user_id": 215,
"target_user": 0,
"reply_user": 0,
"created_at": "2017-07-12 01:13:45",
"updated_at": "2017-07-12 01:13:45",
"commentable_type": "news",
"commentable_id": 31,
"body": "而且其實(shí)我想把這篇資訊分享到我的動(dòng)態(tài),然而……"
},
{
"id": 2388,
"user_id": 215,
"target_user": 0,
"reply_user": 0,
"created_at": "2017-07-12 01:13:01",
"updated_at": "2017-07-12 01:13:01",
"commentable_type": "news",
"commentable_id": 31,
"body": "我下拉到底部后,評論編輯窗口不見了……,"
}
]
}
名稱 | 描述 |
---|---|
pinneds | 置頂評論 |
comments | 評論列表 |
id | 評論id |
user_id | 評論者id |
target_user | 資訊發(fā)布者id |
reply_user | 被回復(fù)者id |
body | 評論內(nèi)容 |
刪除一條資訊評論
DELETE /news/{news}/comments/{comment}
Status: 204 No Content
3.5 收藏、取消收藏資訊信息
收藏資訊
POST /news/{news}/collections
Status: 201 Created
取消收藏資訊
DELETE /news/{news}/collections
Status: 204 No Content
獲取收藏資訊
GET /news/collections
名稱 | 類型 | 必填 | 說明 |
---|---|---|---|
limit | int | - | 數(shù)據(jù)返回條數(shù) |
after | int | - | 數(shù)據(jù)翻頁標(biāo)識(shí) |
Status: 200 Ok
[
{
"id": 2,
"title": "asdasdasdad",
"subject": "阿拉拉啊拉",
"created_at": "2017-08-02 03:28:38",
"updated_at": "2017-08-03 07:53:34",
"from": "原創(chuàng)",
"author": "root",
"user_id": 1,
"hits": 5,
"has_collect": true,
"has_like": false,
"category": {
"id": 1,
"name": "1121",
"rank": 0
},
"image": {
"id": 2,
"size": "370x370"
}
}
]
名稱 | 類型 | 說明 |
---|---|---|
id | int | 數(shù)據(jù)id |
title | string | 資訊標(biāo)題 |
subject | string | 副標(biāo)題 |
from | string | 來源 |
author | string | 作者 |
user_id | int | 發(fā)布者id |
hits | int | 點(diǎn)擊數(shù) |
has_collect | bool | 當(dāng)前用戶是否已收藏 |
has_like | bool | 當(dāng)前用戶是否已點(diǎn)贊 |
category | array | 所屬分類信息 |
category.id | int | 所屬分類id |
category.name | string | 所屬分類名稱 |
category.rank | int | 所屬分類排序 |
image | array | 資訊封面信息 |
image.id | int | 資訊封面附件id |
image.size | string | 資訊封面尺寸 |
3.6 舉報(bào)一個(gè)資訊
POST /news/:news/reports
名稱 | 描述 |
---|---|
reason | 舉報(bào)理由 |
Http Status 201
{
"message": [
"操作成功"
]
}
四、用戶管理
4.1 用戶注冊 - 圖形驗(yàn)證碼
PS: 使用該圖形驗(yàn)證碼的目的是為了防止 短信、郵件 惡意注冊
在這里驗(yàn)證碼驗(yàn)證的過程掌握邏輯即可
<image :src=" 'http://ts.lagou.uieee.com/passport/captcha/' + Math.random() " />
4.2 用戶注冊 - 獲取驗(yàn)證碼
PS:使用驗(yàn)證碼的目的是為了確保用戶注冊電話或者郵箱的唯一性,防止用戶惡意注冊
發(fā)送驗(yàn)證碼支持
phone
非注冊用戶發(fā)送:
POST /verifycodes/register
注冊用戶發(fā)送:
POST /verifycodes
名稱 | 類型 | 描述 |
---|---|---|
phone | String |
如果 email 不存在則必須,以 sms 模式給手機(jī)發(fā)送驗(yàn)證碼。 |
String |
如果 phone 不存在則必須,以 mail 模式給郵箱發(fā)送驗(yàn)證碼。 |
Status: 202 Accepted
{
"message": [
"獲取成功"
]
}
4.3 用戶注冊 - 提交注冊信息
POST /users
名稱 | 類型 | 描述 |
---|---|---|
name | 字符串 | 必須,用戶名 |
phone | 字符串 |
如果 verifiable_type 為 sms 則必須, 手機(jī)號(hào)碼。 |
String |
如果 verifiable_type 為 mail 則必須, E-Mail。 |
|
password | String | 可選,密碼,如果不輸入密碼,允許用戶無密碼注冊。 |
verifiable_type | 枚舉: mail 或 sms
|
必須,驗(yàn)證碼發(fā)送模式。 |
verifiable_code | 字符串或數(shù)字 | 必須,用戶收到的驗(yàn)證碼。(教學(xué)階段驗(yàn)證碼統(tǒng)一使用 8888 ) |
Status: 201 Created
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6Ly9wbHVzLmlvL2FwaS92Mi90b2tlbnMiLCJpYXQiOjE1MDAzNjU5MzQsImV4cCI6MTUwMTU3NTUzNCwibmJmIjoxNTAwMzY1OTM0LCJqdGkiOiJ1aXlvdTQwNnJsdU9pa3l3In0.OTM4mbH3QW7busunRsFUsheE5vysuIfrBrwjWnd0J6k",
"ttl": 20160,
"refresh_ttl": 40320
}
4.4 用戶登陸
POST /auth/login
名稱 | 類型 | 描述 |
---|---|---|
login | 字符串 |
必須,用戶認(rèn)證字段,可以是 name 、 email 和 phone 。 |
password | 字符串 | 可選,用戶密碼。 |
verifiable_code |
string |
可選,登錄驗(yàn)證碼。 |
password
或者verifiable_code
必須選擇一個(gè),如果選擇verifiable_code
進(jìn)行登錄。那么login
字段只能是phone
或者
Status: 20o OK
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vcGx1cy5pby9hcGkvdjIvYXV0aC9sb2dpbiIsImlhdCI6MTUxNTU3NDE0MSwiZXhwIjoxNTE1NTc3NzQxLCJuYmYiOjE1MTU1NzQxNDEsImp0aSI6Imx1MWtFcDd1UjZpWnoxV3giLCJzdWIiOjEsInBydiI6IjQ4ZTQ1MzgzMWNlYmE1ZTU3YTQ3NWU2ODY0OWNmZGVlNmU5N2Q4ZDIifQ.0_u1dgb-rSr2o7nIx4Q1n1NNcr1LMAtgTbKsFFdUvmg",
"token_type": "bearer",
"expires_in": 60,
"refresh_ttl": 20160
}
字段 | 描述 |
---|---|
access_token | 授權(quán) Token |
token_type | Token 類型 |
expires_in | 過期時(shí)間,單位分 |
refresh_ttl | 刷新過期時(shí)間,單位分 |
4.5 用戶退出
POST|PUT|PATCH|GET /auth/logout
需要
認(rèn)證
Status: 200 OK
{
"message": "退出成功"
}
4.6 刷新當(dāng)前用戶 Token
POST|PUT|PATCH|GET /auth/refresh
需要
認(rèn)證
4.7 獲取當(dāng)前登錄用戶未讀消息
Unread message count(未讀消息統(tǒng)計(jì))
GET /user/counts
Status: 200 OK
{
"user": { // 用戶相關(guān)
"following": 1, // 用戶關(guān)注者新增(粉絲新增)數(shù)量
"liked": 0, // 被點(diǎn)贊數(shù)
"commented": 0, // 被評論數(shù)
"system": 0, // 系統(tǒng)消息,
"news-comment-pinned": 0, // 置頂評論消息
"feed-comment-pinned": 0, // 動(dòng)態(tài)置頂消息
"mutual": 0, // 其他消息
"at": 2, // At 我的消息
}
}
At me(@我的)
GET /user/message/atme
Name | Type | Description |
---|---|---|
limit |
integer |
可選,請求的數(shù)據(jù)條數(shù),默認(rèn) 15 ,允許范圍 1 - 100 。 |
index |
integer |
可選,數(shù)據(jù)開始查找的位置標(biāo)記,默認(rèn) 0 ,來源響應(yīng)體的 id 字段。 |
direction |
enum |
可選,以 index 標(biāo)記開始的數(shù)據(jù)順序,默認(rèn) desc ,允許值:asc /desc 。 |
Status: 200 OK
[
{
"id": 1, // 消息 ID
"user_id": 1, // 消息接收人ID(當(dāng)前用戶ID)
"resourceable": { // 資源
"type": "feeds", // 資源類型
"id": 1 // 資源ID
},
"created_at": "2018-08-13T08:06:54Z" // 消息創(chuàng)建時(shí)間
}
]
4.8 獲取當(dāng)前登陸用戶簽到相關(guān)信息
獲取簽到信息
GET /user/checkin
Status: 200 OK
{
"rank_users": [
{
"id": 1,
"name": "Seven",
"bio": "Seven 的個(gè)人傳記",
"sex": 2,
"location": "成都 中國",
"created_at": "2017-06-02 08:43:54",
"updated_at": "2017-07-25 03:59:39",
"avatar": "http://plus.io/api/v2/users/1/avatar",
"bg": "http://plus.io/storage/user-bg/000/000/000/01.png",
"verified": null,
"extra": {
"user_id": 1,
"likes_count": 0,
"comments_count": 8,
"followers_count": 0,
"followings_count": 1,
"updated_at": "2017-08-11 01:32:36",
"feeds_count": 0,
"questions_count": 5,
"answers_count": 3,
"checkin_count": 2,
"last_checkin_count": 2
}
}
],
"checked_in": true,
"checkin_count": 2,
"last_checkin_count": 2,
"attach_balance": 0
}
字段 | 描述 |
---|---|
rank_users | 當(dāng)日前五簽到用戶,按照簽到時(shí)間順序排列。(參考「用戶資料」接口文檔) |
checked_in | 當(dāng)前用戶是否已簽到。 |
checkin_count | 當(dāng)前用戶簽到總天數(shù)。 |
last_checkin_count | 當(dāng)前用戶連續(xù)簽到天數(shù)。 |
attach_balance | 簽到用戶積分增加值,單位是真實(shí)貨幣「分」單位。 |
簽到
PUT /user/checkin
Status: 204 No Content
累計(jì)簽到排行榜
GET /checkin-ranks
名稱 | 類型 | 描述 |
---|---|---|
offset | Integer | 數(shù)據(jù)偏移數(shù),默認(rèn)為 0 。 |
limit | Integer | 查詢數(shù)據(jù)條數(shù) |
Status: 200 OK
[
{
"id": 1,
"name": "Seven",
"bio": "Seven 的個(gè)人傳記",
"sex": 2,
"location": "成都 中國",
"created_at": "2017-06-02 08:43:54",
"updated_at": "2017-07-25 03:59:39",
"follwing": false,
"follower": false,
"avatar": "http://plus.io/api/v2/users/1/avatar",
"bg": "http://plus.io/storage/user-bg/000/000/000/01.png",
"verified": null,
"extra": {
"user_id": 1,
"likes_count": 0,
"comments_count": 8,
"followers_count": 0,
"followings_count": 1,
"updated_at": "2017-08-11 01:32:36",
"feeds_count": 0,
"questions_count": 5,
"answers_count": 3,
"checkin_count": 2,
"last_checkin_count": 2
}
},
{
"id": 2,
"name": "test1",
"bio": null,
"sex": 0,
"location": "0",
"created_at": "2017-06-12 07:38:55",
"updated_at": "2017-06-12 07:38:55",
"follwing": true,
"follower": false,
"avatar": null,
"bg": null,
"verified": null,
"extra": {
"user_id": 2,
"likes_count": 0,
"comments_count": 0,
"followers_count": 0,
"followings_count": 0,
"updated_at": null,
"feeds_count": 0,
"questions_count": 0,
"answers_count": 0,
"checkin_count": 0,
"last_checkin_count": 0
}
}
]
4.9 獲取一個(gè)用戶
- 獲取指定用戶:
GET /users/:user
| 變量 | 描述 |
| user
| 這個(gè)變量可以是「用戶名」、「郵箱」、「手機(jī)號(hào)碼」和「用戶ID」 |
參數(shù) | 類型 | 描述 |
---|---|---|
following | Integer | 檢查請求用戶是否關(guān)注了指定的用戶,傳遞要檢查的用戶 ID,默認(rèn)為當(dāng)前登錄用戶。 |
follower | Integer | 檢查請求用戶是否被某個(gè)用戶關(guān)注,傳遞要檢查的用戶 ID,默認(rèn)為當(dāng)前登錄用戶。 |
- 獲取當(dāng)前認(rèn)證用戶
GET /user
Status: 200 OK
{
"id": 1, // 用戶 ID
"name": "創(chuàng)始人", // 用戶名
"phone": "18364758373", // 用戶手機(jī)號(hào)碼,僅獲取自己資料
"email": "shiweidu@outlook.com", // 用戶郵箱,僅獲取自己資料
"bio": "我是大管理員", // 用戶描述
"sex": 0, // 用戶性別,1 男,2 女,0 未知
"location": "成都市 四川省 中國", // 用戶地區(qū)
"created_at": "2017-06-02 08:43:54",// 用戶注冊時(shí)間
"updated_at": "2017-07-06 07:04:06",// 用戶最后一次更新資料時(shí)間
"avatar": { // 用戶頭像
"vendor": "local",
"url": "https://xxxxx",
"mize": "image/png",
"size": 8674535,
"dimension": {
"width": 240,
"height": 240,
}
},
"bg": null, // 同 `avatar` 字段
"extra": { // 用戶拓展信息
"user_id": 1,
"likes_count": 0, // 喜歡數(shù)量
"comments_count": 0, // 評論數(shù)量
"followers_count": 0, // 關(guān)注者數(shù)量
"followings_count": 1, // 關(guān)注的人數(shù)量
"updated_at": "2017-07-16 09:44:25",
"feeds_count": 0 // 動(dòng)態(tài)數(shù)量
},
"wallet": { // 錢包信息,僅獲取自己資料存在
"id": 1,
"user_id": 1,
"balance": 90, // 錢包余額
"created_at": "2017-06-02 08:43:54",
"updated_at": "2017-07-05 08:29:49",
"deleted_at": null
},
"new_wallet": { // 錢包信息,僅獲取自己資料存在
"owner_id": 1,
"balance": 1000, // 錢包余額
"total_income": 100, // 收入統(tǒng)計(jì)
"total_expenses": 100, // 支出統(tǒng)計(jì)
"created_at": "2018-01-22 10:05:44",
"updated_at": "2018-01-22 10:05:45"
},
"currency": { // 積分信息,僅獲取自己資料存在
"owner_id": 1,
"type": 1, // 積分類型
"sum": 9400, // 積分?jǐn)?shù)量
"created_at": "2018-01-17 06:57:18",
"updated_at": "2018-01-18 06:57:24"
}
}
4.10 更新認(rèn)證用戶資料
- 更新認(rèn)證用戶的手機(jī)號(hào)碼和郵箱
- 更新認(rèn)證用戶密碼
PATCH /user
字段 | 類型 | 描述 |
---|---|---|
name | 字符串 | 用戶新的用戶名。 |
bio | 字符串 | 用戶新的個(gè)人傳記。 |
sex | 數(shù)字 | 用戶新的性別。 |
location | 字符串 | 用戶新的位置信息。 |
avatar |
FILE_STORAGE_NODE<string> |
可選,用戶頭像的 File node 值 |
bg |
FILE_STORAGE_NODE<string> |
可選,用戶背景圖片的 File node 值 |
Status: 204 No Content
- 更新認(rèn)證用戶的手機(jī)號(hào)碼和郵箱
PUT /user
字段 | 類型 | 描述 |
---|---|---|
phone | 字符串 |
如果 email 不存在則必須,用戶新的手機(jī)號(hào)碼。 |
字符串 |
如果 phone 不存在則必須,用戶新的郵箱地址。 |
|
verifiable_code | 字符串或者數(shù)字 | 必須,驗(yàn)證碼。 |
Status: 204 No Content
- 更新認(rèn)證用戶密碼
PUT /user/password
名稱 | 類型 | 描述 |
---|---|---|
old_password | 字符串 | 用戶已設(shè)置密碼時(shí)必須,用戶密碼。 |
password | 字符串 | 必須,用戶的新密碼 |
password_confirmation | 字符串 |
必須,用戶的新密碼,必須和 password 一致。 |
Status: 204 No Content
4.11 獲取所有用戶
GET /users
名稱 | 類型 | 描述 |
---|---|---|
limit |
integer |
可選,請求獲取的數(shù)據(jù)量,默認(rèn)為 20 條,最低獲取 1 條,最多獲取 50 條。 |
order |
string |
可選,排序方式,默認(rèn) desc ,可選 asc 或 desc 。 |
since |
integer |
可選,上次請求的最后一條的 id ,用于獲取這個(gè)用戶之后的數(shù)據(jù)。 |
name |
string |
可選用于檢索包含 name 傳遞字符串用戶名的用戶;如果 fetch_by 是 username 那么這里就是完整的用戶名,多個(gè)用戶名使用 , 進(jìn)行分割。 |
fetch_by |
string |
可選,獲取數(shù)據(jù)的方式,默認(rèn)是 id 已常規(guī)方式進(jìn)行獲取,允許值:username 使用 name 字段進(jìn)行按照用戶名獲取、id 使用 id 字段按照用戶 ID 進(jìn)行獲取。 |
id |
integer or string
|
可選,獲取一個(gè)或者多個(gè)指定的用戶,如果獲取多個(gè)請使用 , 將用戶 ID進(jìn)行字符串拼接。 |
Status: 200 OK
[
{
"id": 1,
"name": "創(chuàng)始人",
"bio": "我是大管理員",
"sex": 0,
"location": "成都市 四川省 中國",
"created_at": "2017-06-02 08:43:54",
"updated_at": "2017-07-06 07:04:06",
"following": false,
"follower": false,
"avatar": "http://plus.io/api/v2/users/1/avatar",
"bg": null,
"extra": {
"user_id": 1,
"likes_count": 0,
"comments_count": 0,
"followers_count": 0,
"followings_count": 1,
"updated_at": "2017-07-16 09:44:25",
"feeds_count": 0
}
}
]
4.12 用戶找回密碼
PUT /user/retrieve-password
名稱 | 類型 | 描述 |
---|---|---|
verifiable_type | 枚舉:mail 或者 sms
|
必須,驗(yàn)證碼發(fā)送模式。 |
verifiable_code | 字符串或者整數(shù) | 必須,用戶收到的驗(yàn)證碼。 |
字符串 | 如果 verifiable_type 值為 mail ,那么這個(gè)字段為必須,用戶郵箱。 |
|
phone | 字符串 | 如果 verifiable_type 值為 sms 。那么這個(gè)字段為必須,用戶手機(jī)號(hào)碼。 |
password | 字符串 | 用戶新密碼。 |
Status: 204 No Content
4.13 解除用戶 Phone 或者 E-Mail 綁定
解除用戶 Phone 綁定:
DELETE /api/v2/user/phone
解除用戶 E-Mail 綁定:
DELETE /api/v2/user/email
名稱 | 類型 | 描述 |
---|---|---|
password | String | 用戶密碼。 |
verifiable_code | Int 或者 String | 手機(jī)號(hào)碼或者郵箱驗(yàn)證碼。 |
Status: 204 No Content
五、文件上傳管理
5.1 獲取文件 hash 信息
PS:通過 微信 API 文件讀取接口讀取文件
filePath
let hash = await new Promise((resolve, reject) => {
uni.getFileInfo({
filePath,
success: (result) => {
resolve(result.digest)
}
})
})
5.2 文件上傳檢查
PS:依賴上一步獲取到的
hash
值文章來源:http://www.zghlxwxcb.cn/news/detail-816706.html
GET /files/uploaded/`hash`
5.3 文件上傳
POST /files
名稱 | 類型 | 描述 |
---|---|---|
file | File | 待上傳的文件 |
Status: 201 Created
{
"message": [
"上傳成功"
],
"id": 1
}
let forms = new FormData()
forms.append('file',uni.getFileSystemManager().readFileSync(`filePath`))
await uni.request({
url: 'http://ts.lagou.uieee.com/api/v2/files',
method: "POST",
forms,
headers: {
'Content-Type': 'multipart/form-data',
'Accept': "application/json",
'Authorization': "Bearer " + uni.getStorageSync("accessToken").data
},
})
5.4 文件獲取
GET /files/:file
這里的 :file 雖然叫做文件,實(shí)際是系統(tǒng)中的 file_with 標(biāo)識(shí),例如上傳返回的都是 file_with 標(biāo)識(shí)。文章來源地址http://www.zghlxwxcb.cn/news/detail-816706.html
到了這里,關(guān)于UniAPP社區(qū)論壇項(xiàng)目實(shí)戰(zhàn)--社區(qū)服務(wù) API 接口文檔的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!