評論

接口約定

  • 使用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
}
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容