接口约定
- 使用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: first_test
接口
获取测试题列表
name | cname | type | Description |
---|---|---|---|
用途 | 获取发音测试、流利度测试、表达测试等测试题 | ||
方式 | GET | ||
版本号 | v1.0 | ||
sub_resource | tests | ||
sub_resource_id | pronunciation(发音测试)/fluency(流利度测试)/express(表达测试) |
请求数据:
query_string 参数
name | cname | type | Description |
---|---|---|---|
limit | 数目 | int | 获取数量 |
例
curl -i "https://babieta.xivan.cn/api/v1.0/first_test/tests/pronunciation?limit=4" -H "openid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/api/v1.0/first_test/tests/pronunciation",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{limit:'4'},
"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 | 错误信息 | |
list | array |
测试题列表 |
例
{"msg": "", "code": 0, "list": ["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."]}
上报测试结果
name | cname | type | Description |
---|---|---|---|
用途 | 上报发音测试、流利度测试、表达测试等测试题识别结果 | ||
方式 | POST | ||
版本号 | v1.0 | ||
sub_resource | tests | ||
sub_resource_id | pronunciation(发音测试)/fluency(流利度测试)/express(表达测试) | ||
action | report_result |
例
curl -XPOST https://babieta.xivan.cn/v1.0/first_test/tests/pronunciation/report_result -d '{"original_text":"abc", "translate_text":"xxx"}' -H "openid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/api/v1.0/first_test/tests/pronunciation/report_result",
"method":"POST",
"success": res =>{
console.log(res)
},
"data":{original_text:"abc", translate_text:"xxx"},
"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 | 错误信息 |
例
{
"code":0,
"msg":""
}
获取成绩
name | cname | type | Description |
---|---|---|---|
用途 | 获取首测三个测验结果和总成绩 | ||
方式 | GET | ||
版本号 | v1.0 | ||
sub_resource | score |
例
curl -XGET https://babieta.xivan.cn/v1.0/first_test/score -H "openid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/v1.0/first_test/score",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{},
"dataType":"json",
"header": { "content-type":"application/json",
"openid": "oslC94mGqAAEz6iWhKhL9dEY5l3o", "token":"25e8ba0469c6f1c0c6dcd4fe952b8e4e"},
"complete": res => {
console.log(res)
}
})
pronunciation_tests(发音测试)/fluency_tests(流利度测试)/express_tests(表达测试)
返回数据:
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
}