接口約定
- 使用https
- restful風(fēng)格
- 用戶端:https://{域名}/api/{接口版本號(hào)}/{resource}/{resource_id}/{sub_resource}/{sub_resource_id}/{action}?{query_string}
- 管理端:https://{域名}/admin/api/{接口版本號(hào)}/{resource}/{resource_id}/{sub_resource}/{sub_resource_id}/{action}?{query_string}
- 測(cè)試環(huán)境域名babieta.xivan.cn
- 正式環(huán)境域名待定
- 公共參數(shù)放在header其障,如userid,session_key,unionid,version等
- resource: exams
接口
GET /exams/{exams_id}/categories/{categories_id}/questions/{questions_id}
name | cname | type | Description |
---|---|---|---|
用途 | 獲取測(cè)試題 | ||
方式 | GET | ||
版本號(hào) | v1.0 | ||
exams_id | first(首次測(cè)驗(yàn))/upgrade(解鎖升級(jí)測(cè)驗(yàn)) | ||
categories_id | pronunciation(發(fā)音測(cè)試)/fluency(流利度測(cè)試)/express(表達(dá)測(cè)試) | ||
questions_id | 可選,目前沒用 |
請(qǐng)求數(shù)據(jù):
query_string 參數(shù)/可選參數(shù)
name | cname | type | Description |
---|---|---|---|
limit | 數(shù)目 | int | 獲取數(shù)量涂佃,默認(rèn)10 |
subject | 數(shù)目 | string | 話題列表,簡(jiǎn)單形式(話題名:數(shù)量), 如subject=節(jié)日:1, 活動(dòng):1 |
例
curl -i "https://babieta.xivan.cn/api/v1.0/exams/first/categories/pronunciation/questions?limit=4&subject=節(jié)日:1, 活動(dòng):1" -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/api/v1.0/exams/first/categories/pronunciation/questions",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{limit:'4'},
"dataType":"json",
"header": { "content-type":"application/x-www-form-urlencoded",
"userid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
返回?cái)?shù)據(jù):
name | cname | type | Description |
---|---|---|---|
code | int | 返回碼 0成功 非0失敗 | |
msg | string | 錯(cuò)誤信息 | |
list | array<object> | 測(cè)試題列表 |
object
name | cname | type | Description |
---|---|---|---|
desc | string | 描述 | |
title | string | 標(biāo)題 | |
id | string | 題目id |
例
發(fā)音
{
"msg": "",
"code": 0,
"list": [{"desc":"Americans called her the \"Queen of Soul,\" and U.S. music industry magazine Billboard2, which maintains charts of popular American songs, lists Franklin as the second-most charted female artist in the chart's 59-year history.", "title":"", "id":2}]
}
流利度
{
"msg": "",
"code": 0,
"list": [{"desc":"描述一個(gè)", "title":"APP", "id":4}, ...]
}
表達(dá)
{
"msg": "",
"code": 0,
"list": [{"desc":"Why do some people like gambling at football, such as the World Cup?", "title":"科技", "id":65}]
}
POST /exams/{exams_id}/categories/{categories_id}/questions/{questions_id}/report_result
name | cname | type | Description |
---|---|---|---|
用途 | 上報(bào)發(fā)音測(cè)試励翼、流利度測(cè)試、表達(dá)測(cè)試等測(cè)試題識(shí)別結(jié)果 | ||
方式 | POST | ||
版本號(hào) | v1.0 | ||
exams_id | first(首次測(cè)驗(yàn))/upgrade(解鎖升級(jí)測(cè)驗(yàn)) | ||
categories_id | pronunciation(發(fā)音測(cè)試)/fluency(流利度測(cè)試)/express(表達(dá)測(cè)試) | ||
action | report_result |
請(qǐng)求數(shù)據(jù):
body 參數(shù)/可選參數(shù)
name | cname | type | Description |
---|---|---|---|
original_text | 原文本 | string | |
translate_text | 用戶語音 | string | |
level | 用戶級(jí)別 | int | |
index | 階段索引 | int |
例
curl -XPOST https://babieta.xivan.cn/v1.0/exams/first/categories/pronunciation/questions/123/report_result -d '{"original_text":"abc", "translate_text":"xxx", "level":0}' -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/v1.0/exams/first/categories/pronunciation/questions/123/report_result",
"method":"POST",
"success": res =>{
console.log(res)
},
"data":{original_text:"abc", translate_text:"xxx"},
"dataType":"json",
"header": { "content-type":"application/json",
"userid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
返回?cái)?shù)據(jù):
name | cname | type | Description |
---|---|---|---|
code | int | 返回碼 0成功 非0失敗 | |
msg | string | 錯(cuò)誤信息 |
例
{
"code":0,
"msg":""
}
GET /exams/{exams_id}/scores
name | cname | type | Description |
---|---|---|---|
用途 | 獲取首測(cè)三個(gè)測(cè)驗(yàn)結(jié)果和總成績(jī) | ||
版本號(hào) | v1.0 | ||
exams_id | first(首次測(cè)驗(yàn))/upgrade(解鎖升級(jí)測(cè)驗(yàn)) | ||
level | 用戶級(jí)別 | int |
例
curl -XGET https://babieta.xivan.cn/v1.0/exams/first/score?level=5 -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/v1.0/first_test/score",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{level:3},
"dataType":"json",
"header": { "content-type":"application/json",
"userid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
返回?cái)?shù)據(jù):
name | cname | type | Description |
---|---|---|---|
code | int | 返回碼 0成功 非0失敗 | |
msg | string | 錯(cuò)誤信息 | |
pronunciation_score | int | 發(fā)音歲數(shù) | |
fluency_score | int | 流利度歲數(shù) | |
express_score | int | 表達(dá)歲數(shù) | |
integrated_score | int | 綜合歲數(shù) |
例
{
"code":0,
"msg":"",
"pronunciation_score":9,
"fluency_score":8,
"express_score":7,
"integrated_score":8
}
POST /exams/{exams_id}/payment
name | cname | type | Description |
---|---|---|---|
用途 | 當(dāng)前等級(jí)測(cè)驗(yàn)支付 | ||
方式 | POST | ||
版本號(hào) | v1.0 | ||
exams_id | upgrade(解鎖升級(jí)測(cè)驗(yàn)) |
例
curl -XPOST https://babieta.xivan.cn/v1.0/exams/upgrade/payment -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/v1.0/exams/upgrade/payment",
"method":"POST",
"success": res =>{
console.log(res)
},
"data":{"level":3},
"dataType":"json",
"header": { "content-type":"application/json",
"userid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
返回?cái)?shù)據(jù):
name | cname | type | Description |
---|---|---|---|
code | int | 返回碼 0成功 非0失敗 | |
msg | string | 錯(cuò)誤信息 |
POST /exams/{exams_id}/retry
name | cname | type | Description | |
---|---|---|---|---|
用途 | 重新開始當(dāng)前測(cè)驗(yàn) | |||
方式 | POST | |||
版本號(hào) | v1.0 | |||
exams_id | upgrade(解鎖升級(jí)測(cè)驗(yàn)) | first(首測(cè)) |
請(qǐng)求數(shù)據(jù):
body 參數(shù)/可選參數(shù)
name | cname | type | Description |
---|---|---|---|
level | 用戶級(jí)別 | int |
例
curl -XPOST https://babieta.xivan.cn/v1.0/exams/upgrade/retry-H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e" -d '{"level":3}'
wx.request({
"url":"https://babieta.xivan.cn/v1.0/exams/upgrade/retry",
"method":"POST",
"success": res =>{
console.log(res)
},
"data":{level:3},
"dataType":"json",
"header": { "content-type":"application/json",
"userid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
返回?cái)?shù)據(jù):
name | cname | type | Description |
---|---|---|---|
code | int | 返回碼 0成功 非0失敗 | |
msg | string | 錯(cuò)誤信息 |
GET /exams/last_score
name | cname | type | Description |
---|---|---|---|
用途 | 獲取首測(cè)三個(gè)測(cè)驗(yàn)結(jié)果和總成績(jī) | ||
版本號(hào) | v1.0 |
例
curl -XGET https://babieta.xivan.cn/v1.0/exams/last_score -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/v1.0/exams/last_score",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{level:3},
"dataType":"json",
"header": { "content-type":"application/json",
"userid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
返回?cái)?shù)據(jù):
name | cname | type | Description |
---|---|---|---|
code | int | 返回碼 0成功 非0失敗 | |
msg | string | 錯(cuò)誤信息 | |
pronunciation_score | int | 發(fā)音歲數(shù) | |
fluency_score | int | 流利度歲數(shù) | |
express_score | int | 表達(dá)歲數(shù) | |
integrated_score | int | 綜合歲數(shù) | |
exam_id | string | first:首測(cè)辜荠,upgrade:自測(cè) |
例
{
"code":0,
"msg":"",
"pronunciation_score":9,
"fluency_score":8,
"express_score":7,
"integrated_score":8,
"exam_id":"first"
}