接口约定
- 使用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: exams
接口
GET /exams/{exams_id}/categories/{categories_id}/questions/{questions_id}
name | cname | type | Description |
---|---|---|---|
用途 | 获取测试题 | ||
方式 | GET | ||
版本号 | v1.0 | ||
exams_id | first(首次测验)/upgrade(解锁升级测验) | ||
categories_id | pronunciation(发音测试)/fluency(流利度测试)/express(表达测试) | ||
questions_id | 可选,目前没用 |
请求数据:
query_string 参数/可选参数
name | cname | type | Description |
---|---|---|---|
limit | 数目 | int | 获取数量,默认10 |
subject | 数目 | string | 话题列表,简单形式(话题名:数量), 如subject=节日:1, 活动:1 |
例
curl -i "https://babieta.xivan.cn/api/v1.0/exams/first/categories/pronunciation/questions?limit=4&subject=节日:1, 活动: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)
}
})
返回数据:
name | cname | type | Description |
---|---|---|---|
code | int | 返回码 0成功 非0失败 | |
msg | string | 错误信息 | |
list | array<object> | 测试题列表 |
object
name | cname | type | Description |
---|---|---|---|
desc | string | 描述 | |
title | string | 标题 | |
id | string | 题目id |
例
发音
{
"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":"描述一个", "title":"APP", "id":4}, ...]
}
表达
{
"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 |
---|---|---|---|
用途 | 上报发音测试、流利度测试、表达测试等测试题识别结果 | ||
方式 | POST | ||
版本号 | v1.0 | ||
exams_id | first(首次测验)/upgrade(解锁升级测验) | ||
categories_id | pronunciation(发音测试)/fluency(流利度测试)/express(表达测试) | ||
action | report_result |
请求数据:
body 参数/可选参数
name | cname | type | Description |
---|---|---|---|
original_text | 原文本 | string | |
translate_text | 用户语音 | string | |
level | 用户级别 | 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)
}
})
返回数据:
name | cname | type | Description |
---|---|---|---|
code | int | 返回码 0成功 非0失败 | |
msg | string | 错误信息 |
例
{
"code":0,
"msg":""
}
GET /exams/{exams_id}/scores
name | cname | type | Description |
---|---|---|---|
用途 | 获取首测三个测验结果和总成绩 | ||
版本号 | v1.0 | ||
exams_id | first(首次测验)/upgrade(解锁升级测验) | ||
level | 用户级别 | 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)
}
})
返回数据:
name | cname | type | Description |
---|---|---|---|
code | int | 返回码 0成功 非0失败 | |
msg | string | 错误信息 | |
pronunciation_score | int | 发音岁数 | |
fluency_score | int | 流利度岁数 | |
express_score | int | 表达岁数 | |
integrated_score | int | 综合岁数 |
例
{
"code":0,
"msg":"",
"pronunciation_score":9,
"fluency_score":8,
"express_score":7,
"integrated_score":8
}
POST /exams/{exams_id}/payment
name | cname | type | Description |
---|---|---|---|
用途 | 当前等级测验支付 | ||
方式 | POST | ||
版本号 | v1.0 | ||
exams_id | upgrade(解锁升级测验) |
例
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)
}
})
返回数据:
name | cname | type | Description |
---|---|---|---|
code | int | 返回码 0成功 非0失败 | |
msg | string | 错误信息 |
POST /exams/{exams_id}/retry
name | cname | type | Description | |
---|---|---|---|---|
用途 | 重新开始当前测验 | |||
方式 | POST | |||
版本号 | v1.0 | |||
exams_id | upgrade(解锁升级测验) | first(首测) |
请求数据:
body 参数/可选参数
name | cname | type | Description |
---|---|---|---|
level | 用户级别 | 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)
}
})
返回数据:
name | cname | type | Description |
---|---|---|---|
code | int | 返回码 0成功 非0失败 | |
msg | string | 错误信息 |
GET /exams/last_score
name | cname | type | Description |
---|---|---|---|
用途 | 获取首测三个测验结果和总成绩 | ||
版本号 | 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)
}
})
返回数据:
name | cname | type | Description |
---|---|---|---|
code | int | 返回码 0成功 非0失败 | |
msg | string | 错误信息 | |
pronunciation_score | int | 发音岁数 | |
fluency_score | int | 流利度岁数 | |
express_score | int | 表达岁数 | |
integrated_score | int | 综合岁数 | |
exam_id | string | first:首测,upgrade:自测 |
例
{
"code":0,
"msg":"",
"pronunciation_score":9,
"fluency_score":8,
"express_score":7,
"integrated_score":8,
"exam_id":"first"
}