接口約定
- 使用https
- restful風(fēng)格
- 用戶端: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}
- 測試環(huán)境域名babieta.xivan.cn
- 正式環(huán)境域名待定
- 公共參數(shù)放在header,如userid,token,unionid,version等
- resource: auth
接口
POST /auth/login
| name | cname | type | Description |
|---|---|---|---|
| 用途 | 用戶登錄,無注冊態(tài)則自動注冊 | ||
| 版本號 | v1.0 |
請求數(shù)據(jù):
query_string 參數(shù)
| name | cname | type | Description |
|---|---|---|---|
| avatar_url | 頭像 | string | |
| city | 城市 | string | |
| country | 國家 | string | |
| gender | 性別 | string | |
| language | 語言 | string | |
| nickname | 昵稱 | string | |
| province | 省份 | string |
例
curl -XPOST https://babieta.xivan.cn/api/v1.0/auth/login -d '{"code":"xxx", "nickname":"134",...}'
wx.request({
"url": "https://babieta.xivan.cn/api/v1.0/auth/login",
"method": "POST",
"success": res => {
console.log(res)
},
"data": { code: "023RaD4B04iEDg2jV93B0RCC4B0RaD4o", "nickname":"134", ... },
"dataType": "json",
"header": {
"content-type": "application/json",
},
"complete": res => {
console.log(res)
}
})
返回數(shù)據(jù):
| name | cname | type | Description |
|---|---|---|---|
| code | int | 返回碼 0成功 非0失敗 | |
| msg | string | 錯誤信息 | |
| userid | string | ||
| token | string | 登錄憑證 |
例
{
"code"0,
"msg":"",
"userid":"123",
"token":"xxxx"
}