接口約定
- 使用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,session_key,unionid,version等
- resource: first_test
接口
獲取測試題列表
| name | cname | type | Description |
|---|---|---|---|
| 用途 | 獲取發(fā)音測試、流利度測試、表達(dá)測試等測試題 | ||
| 方式 | GET | ||
| 版本號 | v1.0 | ||
| sub_resource | tests | ||
| sub_resource_id | pronunciation(發(fā)音測試)/fluency(流利度測試)/express(表達(dá)測試) |
請求數(shù)據(jù):
query_string 參數(shù)
| name | cname | type | Description |
|---|---|---|---|
| limit | 數(shù)目 | int | 獲取數(shù)量 |
例
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)
}
})
返回數(shù)據(jù):
| name | cname | type | Description |
|---|---|---|---|
| code | int | 返回碼 0成功 非0失敗 | |
| msg | string | 錯誤信息 | |
| list | array<string> | 測試題列表 |
例
{"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."]}
上報測試結(jié)果
| name | cname | type | Description |
|---|---|---|---|
| 用途 | 上報發(fā)音測試、流利度測試、表達(dá)測試等測試題識別結(jié)果 | ||
| 方式 | POST | ||
| 版本號 | v1.0 | ||
| sub_resource | tests | ||
| sub_resource_id | pronunciation(發(fā)音測試)/fluency(流利度測試)/express(表達(dá)測試) | ||
| 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)
}
})
返回數(shù)據(jù):
| name | cname | type | Description |
|---|---|---|---|
| code | int | 返回碼 0成功 非0失敗 | |
| msg | string | 錯誤信息 |
例
{
"code":0,
"msg":""
}
獲取成績
| name | cname | type | Description |
|---|---|---|---|
| 用途 | 獲取首測三個測驗結(jié)果和總成績 | ||
| 方式 | 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(發(fā)音測試)/fluency_tests(流利度測試)/express_tests(表達(dá)測試)
返回數(shù)據(jù):
| name | cname | type | Description |
|---|---|---|---|
| code | int | 返回碼 0成功 非0失敗 | |
| msg | string | 錯誤信息 | |
| 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
}