新增和修改视频问答
接口URL
https://api.polyv.net/v2/video/save-video-exam
接口说明
新增和修改问答
支持格式
JSON
请求方式
POST
请求参数
参数名
必选
类型及范围
说明
userid
是
string
用户ID
ptime
是
long
当前时间的毫秒级时间戳(13位),3分钟内有效
vid
是
string
视频ID
examId
否
string
问答ID,为空时会新增一个题目。不为空时会修改已有的问答题目
showTime
是
int
问答出现的时间,单位:秒
qustion
是
string
问答题目描述
choices
是
array of string
问答选项json数组,每个题目最多5个选项
canSkip
否
boolean
是否可跳过,默认值:false
explanationIfRight
否
string
回答正确后的解答详情
showExplanationIfWrong
否
boolean
回答答错误后是否显示解答详情,默认值:true
explanationIfWrong
否
string
回答错误后的解答详情
backTime
否
int
答错后回退到第几秒,-1代表不回退,默认为-1
choices参数说明
示例
[
{
"index": 0,
"content": "a",
"isRight": true
},
{
"index": 1,
"content": "b",
"isRight": false
},
{
"index": 2,
"content": "c",
"isRight": false
},
{
"index": 3,
"content": "d",
"isRight": true
}
]
参数名
必选
类型及范围
说明
index
是
int
选项序号,题目实际顺序为按此值的大小排序,不要重复
content
是
string
选项内容
isRight
否
boolean
所有选项中必须至少有一个设置为正确答案,否则接口返回错误。
返回正确结果JSON示例
{
"code": 200,
"status": "success",
"message": "success",
"data": {
"examId": "179228dfe4f"
}
}
返回错误结果JSON示例
签名不正确
{
"code":400,
"status":"error",
"message":"the sign is not right",
"data":""
}
时间戳过期
{
"code":400,
"status":"error",
"message":"ptime is too old.",
"data":""
}
vid 不存在
{
"code": 400,
"status": "error",
"message": "video could not find by vid",
"data": ""
}
字段说明
字段
说明
code
返回码
status
返回状态
message
返回信息
data
操作结果
examId
问答ID
java请求示例:
public void testSaveVideoExam() throws Exception {
String url = "https://api.polyv.net/v2/video/save-video-exam";
Map<String, String> params = new HashMap<>();
params.put("userid", userid);
params.put("vid", "a2dc4f25172872650e7d5c1b8026b13c_a");
params.put("examId", "179228dfe4f");
params.put("question", "测试问题");
params.put("showTime", "12");
params.put("choices", "[{\"index\":0,\"content\":\"a\",\"isRight\":true},{\"index\":1,\"content\":\"b\",\"isRight\":false},{\"index\":2,\"content\":\"c\",\"isRight\":false},{\"index\":3,\"content\":\"d\",\"isRight\":true}]");
params.put("canSkip", "false");
params.put("explanationIfRight", "回答正确后的解答详情");
params.put("showExplanationIfWrong", "true");
params.put("explanationIfWrong", "回答错误后的解答详情");
params.put("backTime", "1");
params.put("ptime", String.valueOf(System.currentTimeMillis()));
params.put("sign", getSign(params, secretkey));
String response = HttpClientUtil.getInstance().sendHttpPost(url, params);
System.out.println(response);
}
Last updated
Was this helpful?