接口約定
- 使用https
- restful風格
- 用戶端:https://{域名}/api/{接口版本號}/{resource}/{resource_id}/{sub_resource}/{sub_resource_id}/{action}?{query_string}
- 管理端:https://{域名}/admin/api/{接口版本號}/{resource}/{resource_id}/{sub_resource}/{sub_resource_id}/{action}?{query_string}
- 測試環境域名babieta.xivan.cn
- 正式環境域名待定
- 公共參數放在header,如userid,session_key,unionid,version等
- resource: comments
接口
POST /comments/<busi_type>/<busi_id>
name | cname | type | Description |
---|---|---|---|
用途 | 評論 | ||
版本號 | v1.0 | ||
busi_type | 業務類型 | string | soak(浸泡訓練) |
busi_id | 業務id | string |
請求數據:
body 參數/可選參數
name | cname | type | Description |
---|---|---|---|
text | 評論內容 | string |
例
curl -i -XPOST "https://babieta.xivan.cn/api/v1.0/comments/soak/1" -H "openid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e" -d '{"text":"內容"}'
wx.request({
"url":"https://babieta.xivan.cn/api/v1.0/comments/soak/1",
"method":"POST",
"success": res =>{
console.log(res)
},
"data":{text:'內容'},
"dataType":"json",
"header": { "content-type":"application/json",
"openid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
返回數據:
name | cname | type | Description |
---|---|---|---|
code | int | 返回碼 0成功 非0失敗 | |
msg | string | 錯誤信息 |
例
{
"msg": "",
"code": 0,
}
GET /comments/<busi_type>/<busi_id>
name | cname | type | Description |
---|---|---|---|
用途 | 評論 | ||
版本號 | v1.0 | ||
busi_type | 業務類型 | string | soak(浸泡訓練) |
busi_id | 業務id | string |
請求數據:
query string 參數/可選參數
name | cname | type | Description |
---|---|---|---|
cursor | 游標,用于分頁 | string | 取上一次頁面的cursor透傳,默認不傳或空 |
limit | 數量 | int | 默認10 |
例
curl -i "https://babieta.xivan.cn/api/v1.0/comment/soak/1?limit=10&cursor=10" -H "openid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/api/v1.0/comment/soak/1?limit=10&cursor=10",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{busi_type:'soak', busi_id:1, limit:10, last_id='1123'},
"dataType":"json",
"header": { "content-type":"application/x-www-form-urlencoded",
"openid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
返回數據:
name | cname | type | Description |
---|---|---|---|
code | int | 返回碼 0成功 非0失敗 | |
msg | string | 錯誤信息 |
例
{
"msg": "",
"code": 0,
"list": [{
"id":"11", //評論id
"content":"abc", //評論內容
"comment_ts":1111111, //評論時間
"comment_user": { //評論人信息
"nickname":"aa" , //昵稱
"avatar_url":"http://111.jpg", //頭像
"userid":"1232", //id
"level":10 //級別
},
"praise_count":10 //點贊數,
"praise_flag":1 //點贊狀態 1 已點贊 0 未點贊
},...],
"count":123,//評論類型
"cursor":"111" //透傳id
}