国开对接API
一、约定
密钥签名
- post 过滤的数据 $body 与密钥拼接 md5得到 sign
- md5($body+$key)
- 通过 ?sign=xxxxx get的方式传输过来
php
$body = file_get_contents('php://input') ;
$body= trim( $body );
$sign = md5($str . $key );$body = file_get_contents('php://input') ;
$body= trim( $body );
$sign = md5($str . $key );提交
shell
curl --request POST \
--url 'http://url.cn/api?sign=xxxxx' \
--header 'content-type: application/json' \
--data '{
"openId": "xxxx",
"id": "1233",
}'curl --request POST \
--url 'http://url.cn/api?sign=xxxxx' \
--header 'content-type: application/json' \
--data '{
"openId": "xxxx",
"id": "1233",
}'返回体
json
{
"data": [], //成功返回的数据
"error": 502, //当0的时候为成功,非0表示错误代码
"error_des": "失败原因"
}{
"data": [], //成功返回的数据
"error": 502, //当0的时候为成功,非0表示错误代码
"error_des": "失败原因"
}二、布置作文接口
接口地址:
http://url.cn/ouchn/request?sign=xxxx
提交JSON数据
json
{
"openId": "xxx",
"taskId": "d2067706",
"taskTitle": "新增英文作业",
"taskRequest": "god",
"start": "2023-02-08 11:11:15",
"end": "2023-02-12 11:11:00",
"userNo": "testt95",
"taskFatherId": "2067707"
}{
"openId": "xxx",
"taskId": "d2067706",
"taskTitle": "新增英文作业",
"taskRequest": "god",
"start": "2023-02-08 11:11:15",
"end": "2023-02-12 11:11:00",
"userNo": "testt95",
"taskFatherId": "2067707"
}| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| openId | string | 是 | 用户唯一标识 |
| taskId | string | 是 | 合作方任务id |
| taskTitle | string | 是 | 任务标题 |
| taskRequest | string | 是 | 任务要求 |
| start | string | 是 | 答题开始时间 |
| end | string | 是 | 答题截止时间 |
| userNo | string | 是 | 用户工号 |
| taskFatherId | string | 否 | 模版父任务id 引用布置 |
返回说明
json
{
"father": {
"id": "20",
"task_id": "2067707",
"pigai_id": "2804413",
"openid": "xxxx",
"type": "1"
},
"taskId": "c20677099",
"openId": "xxxx",
"pigaiRequestId": "2978616",
"url": "https://www.pigai.org/ouchn/url/setting/2978616",
"taskUrl": "https://www.pigai.org/ouchn/url/task/2978616"
}{
"father": {
"id": "20",
"task_id": "2067707",
"pigai_id": "2804413",
"openid": "xxxx",
"type": "1"
},
"taskId": "c20677099",
"openId": "xxxx",
"pigaiRequestId": "2978616",
"url": "https://www.pigai.org/ouchn/url/setting/2978616",
"taskUrl": "https://www.pigai.org/ouchn/url/task/2978616"
}| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| father | object | 否 | 模版父任务id 引用布置 相关信息 |
| taskId | string | 是 | 合作方任务id |
| openId | string | 是 | 用户唯一标识 |
| pigaiRequestId | string | 是 | 批改网作文号 |
| url | string | 是 | 作文设置链接 |
| taskUrl | string | 是 | 任务答题链接 |
三、修改作文接口
接口地址:
http://url.cn/ouchn/requestModify?sign=xxxx
提交JSON数据
json
{
"openId": "xxxx",
"taskId": "ttt",
"taskTitle": "蓝本课作业",
"taskRequest": " ",
"start": "2023-02-09 17:58:00",
"end": "2023-02-19 17:54:00"
}{
"openId": "xxxx",
"taskId": "ttt",
"taskTitle": "蓝本课作业",
"taskRequest": " ",
"start": "2023-02-09 17:58:00",
"end": "2023-02-19 17:54:00"
}| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| openId | string | 是 | 用户唯一标识 |
| taskId | string | 是 | 合作方任务id |
| taskTitle | string | 否 | 任务标题 |
| taskRequest | string | 否 | 任务要求 |
| start | string | 否 | 答题开始时间 |
| end | string | 否 | 答题截止时间 |
返回说明
json
{
"taskId": "789943",
"openId": "xxxx",
"pigaiRequestId": "2804371",
"url": "https://www.pigai.org/ouchn/url/setting/2804371",
"taskUrl": "https://www.pigai.org/ouchn/url/task/2804371",
"pigaiRequestTime": "2023-11-30 22:14:38"
}{
"taskId": "789943",
"openId": "xxxx",
"pigaiRequestId": "2804371",
"url": "https://www.pigai.org/ouchn/url/setting/2804371",
"taskUrl": "https://www.pigai.org/ouchn/url/task/2804371",
"pigaiRequestTime": "2023-11-30 22:14:38"
}| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| taskId | string | 是 | 合作方任务id |
| openId | string | 是 | 用户唯一标识 |
| pigaiRequestId | string | 是 | 批改网作文号 |
| url | string | 是 | 作文设置链接 |
| taskUrl | string | 是 | 任务答题链接 |
| pigaiRequestTime | string | 是 | 修改时间 |
四、删除作文题目
接口地址:
http://url.cn/ouchn/requestDel?sign=xxxx
提交JSON数据
json
{
"pigaiRequestId": "2804381",
"taskId": "2067695"
}{
"pigaiRequestId": "2804381",
"taskId": "2067695"
}| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| pigaiRequestId | string | 是 | 批改网作文号 |
| taskId | string | 是 | 合作方任务id |
返回说明
json
{
"taskId": "789943",
"stats": "success",
"pigaiRequestId": "2804371",
"delEssayCnt": "3"
}{
"taskId": "789943",
"stats": "success",
"pigaiRequestId": "2804371",
"delEssayCnt": "3"
}| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| taskId | string | 是 | 合作方任务id |
| stats | string | 是 | 执行结果 |
| pigaiRequestId | string | 是 | 批改网作文号 |
| delEssayCnt | string | 是 | 删除完的答题作文 |
五、删除单篇作文
接口地址:
http://url.cn/ouchn/essayDel?sign=xxxx
提交JSON数据
json
{
"pigaiEssayId": "174018986"
}{
"pigaiEssayId": "174018986"
}| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| pigaiEssayId | string | 是 | 批改网单篇作文ID |
返回说明
json
{
"stats": "success"
}{
"stats": "success"
}| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| stats | string | 是 | 执行结果 |
六、回传
是将批改网作文批改后的分数、教师操作等动作 回传到合作方
接口地址:
https://lms-product.tronclass.com.cn/external-api/v2/pigai/score-callback?app_key=xxxx&ts=1675673795&token=
json
{
"openId": "xxxx",
"score": "70.3619",
"type": "1",
"time": "2023-02-06 13:33:10",
"url": "https://www.pigai.org/ouchn/url/essay/174034089",
"pigaiEssayId": "174034089",
"pigaiRequestId": "2803785",
"taskId": "test78955"
}{
"openId": "xxxx",
"score": "70.3619",
"type": "1",
"time": "2023-02-06 13:33:10",
"url": "https://www.pigai.org/ouchn/url/essay/174034089",
"pigaiEssayId": "174034089",
"pigaiRequestId": "2803785",
"taskId": "test78955"
}| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| openId | string | 是 | 用户唯一标识 |
| score | string | 是 | 评分 |
| type | string | 是 | 2为教师评分,1为机器评分 |
| time | string | 是 | 时间 |
| url | string | 是 | 作文地址 |
| pigaiEssayId | string | 是 | 批改网单篇作文ID |
| pigaiRequestId | string | 是 | 批改网作文号 |
| taskId | string | 是 | 合作方任务id |
HIGO