接口約定
- 使用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: studies
接口
gcid算法
def gcid_hash_file(path):
h = hashlib.sha1()
size = os.path.getsize(path)
psize = 0x40000
while size / psize > 0x200 and psize < 0x200000:
psize = psize << 1
with open(path, 'rb') as stream:
data = stream.read(psize)
while data:
h.update(hashlib.sha1(data).digest())
data = stream.read(psize)
return h.hexdigest()
GET /studies/auth/qiniu/tokens/<gcid>
name |
cname |
type |
Description |
用途 |
|
|
獲取七牛token |
版本號(hào) |
|
|
v1.0 |
gcid |
|
|
gcid |
例
curl -XGET https://babieta.xivan.cn/api/v1.0/auth/qiniu/tokens/abc
返回?cái)?shù)據(jù):
name |
cname |
type |
Description |
code |
|
int |
返回碼 0成功 非0失敗 |
msg |
|
string |
錯(cuò)誤信息 |
token |
|
string |
上傳文件憑證(5分鐘有效) |
key |
|
string |
上傳文件key |
例
{
"code"0,
"msg":"",
"token":"xxxx",
"key":"yyyy"
}
GET /studies/{studies_id}/contents
name |
cname |
type |
Description |
用途 |
|
|
獲取測(cè)試題 |
版本號(hào) |
|
|
v1.0 |
studies_id |
|
|
express(表達(dá)訓(xùn)練)/soak(浸泡訓(xùn)練)/communication(交流訓(xùn)練) |
請(qǐng)求數(shù)據(jù):
query_string 參數(shù)/可選參數(shù)
name |
cname |
type |
Description |
limit |
數(shù)目 |
int |
獲取數(shù)量顷帖, 默認(rèn)1 |
level |
等級(jí) |
int |
等級(jí) |
flag |
標(biāo)識(shí) |
int |
默認(rèn)0.獲取需要練習(xí)的列表听怕, 1.獲取當(dāng)天已完成的列表 |
例
curl -i "https://babieta.xivan.cn/api/v1.0/studies/express/contents?limit=1&level=3" -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/api/v1.0/studies/express/contents?limit=1",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{limit:'1'},
"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è)試題列表 |
list[].object |
|
array<object> |
測(cè)試題, 不同類型具體看下面定義 |
object->express_info(表達(dá)訓(xùn)練)
name |
cname |
type |
Description |
id |
|
int |
id |
title |
|
string |
標(biāo)題 |
cover_url |
|
int |
單詞圖片 |
word_chi |
|
string |
單詞中文 |
audio_text |
|
string |
語音文本 |
audio_url |
|
string |
語音播放url |
object->soak_info(浸泡訓(xùn)練)
name |
cname |
type |
Description |
id |
|
int |
id |
title |
|
string |
標(biāo)題 |
cover_url |
|
int |
語音圖片 |
audio_url |
|
string |
語音播放url |
object->communication_info(交流訓(xùn)練)
name |
cname |
type |
Description |
id |
|
int |
id |
title |
|
string |
標(biāo)題 |
audio_text |
|
string |
語音文本 |
audio_url |
|
string |
語音播放url |
例
{
"msg": "",
"code": 0,
"list": [{"id":1, "cover_url":"111", "audio_url":"222", "word_chi":"111", "audio_text":"333"}]
}
POST /studies/{studies_id}/contents/{contents_id}/report
name |
cname |
type |
Description |
用途 |
|
|
上報(bào)修習(xí)結(jié)果 |
版本號(hào) |
|
|
v1.0 |
studies_id |
|
|
express(表達(dá)訓(xùn)練)/soak(浸泡訓(xùn)練)/communication(交流訓(xùn)練) |
contents_id |
|
|
題目id |
請(qǐng)求數(shù)據(jù):
body 參數(shù)/可選參數(shù) (get)
name |
cname |
type |
Description |
duration |
時(shí)長(zhǎng) |
int |
時(shí)長(zhǎng)(秒) |
status |
通過狀態(tài) |
int |
默認(rèn)1 通過, 0:不通過 |
例
curl -XPOST -i "https://babieta.xivan.cn/admin/api/v1.0/studies/express/contents/3" -H "Content-Type:application/json" -d '{"duration":"100"}' -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
返回?cái)?shù)據(jù):
name |
cname |
type |
Description |
code |
|
int |
返回碼 0成功 非0失敗 |
msg |
|
string |
錯(cuò)誤信息 |
GET /studies/communication/contents/<content_id>/sound_records
name |
cname |
type |
Description |
用途 |
|
|
獲取交流的錄音列表 |
版本號(hào) |
|
|
v1.0 |
content_id |
|
|
題目id |
請(qǐng)求數(shù)據(jù):
query_string 參數(shù)/可選參數(shù)
name |
cname |
type |
Description |
limit |
數(shù)目 |
int |
獲取數(shù)量钉蒲, 默認(rèn)10 |
例
curl -i "https://babieta.xivan.cn/api/v1.0/studies/communication/contents/4/sound_records?limit=10" -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/api/v1.0/studies/communication/contents/4/sound_records",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{limit:'10'},
"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 |
Descriptio n |
code |
|
int |
返回碼 0成功 非0失敗 |
msg |
|
string |
錯(cuò)誤信息 |
list |
|
array<object> |
錄音列表 |
list[].id |
|
int |
錄音id |
list[].audio_url |
|
string |
錄音鏈接 |
list[].audio_duration |
|
int |
錄音時(shí)長(zhǎng)(秒) |
list[].userid |
|
int |
錄音人id |
list[].nickname |
|
int |
錄音人名 |
list[].avatar_url |
|
int |
錄音人頭像 |
list[].praise_count |
|
int |
點(diǎn)贊數(shù) |
list[].praise_flag |
|
int |
0:未點(diǎn)贊们镜,1已點(diǎn)贊 |
例
{
"msg": "",
"code": 0,
"list": [{"id":1, "audio_duration":111, "audio_url":"222", "user_name":"111", "user_portrait":"333", "praise_count":3}]
}
GET /studies/communication/contents/<content_id>/history_sound_records
name |
cname |
type |
Description |
用途 |
|
|
獲取交流的錄音列表 |
版本號(hào) |
|
|
v1.0 |
content_id |
|
|
題目id |
請(qǐng)求數(shù)據(jù):
query_string 參數(shù)/可選參數(shù)
name |
cname |
type |
Description |
limit |
數(shù)目 |
int |
獲取每個(gè)contentid對(duì)應(yīng)的錄音數(shù)量缴渊, 默認(rèn)10 |
例
curl -i "https://babieta.xivan.cn/api/v1.0/studies/communication/contents/1,2,3,4/history_sound_records?limit=10" -H "userid:oslC94mGqAAEz6iWhKhL9dEY5l3o" -H "token:25e8ba0469c6f1c0c6dcd4fe952b8e4e"
wx.request({
"url":"https://babieta.xivan.cn/api/v1.0/studies/communication/contents/1,2,3,4/history_sound_records",
"method":"GET",
"success": res =>{
console.log(res)
},
"data":{limit:'10'},
"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 |
Descriptio n |
code |
|
int |
返回碼 0成功 非0失敗 |
msg |
|
string |
錯(cuò)誤信息 |
list |
|
array<object> |
問題列表 |
list[] |
|
array<object> |
錄音列表 |
list[][].id |
|
int |
錄音id |
list[][].audio_url |
|
string |
錄音鏈接 |
list[][].audio_duration |
|
int |
錄音時(shí)長(zhǎng)(秒) |
list[][].userid |
|
int |
錄音人id |
list[][].nickname |
|
int |
錄音人名 |
list[][].avatar_url |
|
int |
錄音人頭像 |
list[][].praise_count |
|
int |
點(diǎn)贊數(shù) |
例
{
"msg": "",
"code": 0,
"list": [[{"id":1, "audio_duration":111, "audio_url":"222", "user_name":"111", "user_portrait":"333", "praise_count":3}, ...], [], [], []]
}
POST /studies/communication/contents/<content_id>/sound_records/commit
name |
cname |
type |
Description |
用途 |
|
|
提交交流的錄音 |
版本號(hào) |
|
|
v1.0 |
content_id |
|
|
題目id |
請(qǐng)求數(shù)據(jù):
body 參數(shù)/可選參數(shù)
name |
cname |
type |
Description |
audio_gcid |
gcid |
int |
音頻內(nèi)容md5后的字符串 |
audio_duration |
|
int |
錄音時(shí)長(zhǎng)(秒) |
返回?cái)?shù)據(jù):
name |
cname |
type |
Description |
code |
|
int |
返回碼 0成功 非0失敗 |
msg |
|
string |
錯(cuò)誤信息 |