Skip to content

国开对接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"
}
名称类型必填说明
openIdstring用户唯一标识
taskIdstring合作方任务id
taskTitlestring任务标题
taskRequeststring任务要求
startstring答题开始时间
endstring答题截止时间
userNostring用户工号
taskFatherIdstring模版父任务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"
	}
名称类型必填说明
fatherobject模版父任务id 引用布置 相关信息
taskIdstring合作方任务id
openIdstring用户唯一标识
pigaiRequestIdstring批改网作文号
urlstring作文设置链接
taskUrlstring任务答题链接

三、修改作文接口

接口地址: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"
}
名称类型必填说明
openIdstring用户唯一标识
taskIdstring合作方任务id
taskTitlestring任务标题
taskRequeststring任务要求
startstring答题开始时间
endstring答题截止时间

返回说明

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"
}
名称类型必填说明
taskIdstring合作方任务id
openIdstring用户唯一标识
pigaiRequestIdstring批改网作文号
urlstring作文设置链接
taskUrlstring任务答题链接
pigaiRequestTimestring修改时间

四、删除作文题目

接口地址:http://url.cn/ouchn/requestDel?sign=xxxx

提交JSON数据

json
{
	"pigaiRequestId": "2804381",
	"taskId": "2067695"
}
{
	"pigaiRequestId": "2804381",
	"taskId": "2067695"
}
名称类型必填说明
pigaiRequestIdstring批改网作文号
taskIdstring合作方任务id

返回说明

json
{
    "taskId": "789943",
    "stats": "success",
    "pigaiRequestId": "2804371",
    "delEssayCnt": "3"
}
{
    "taskId": "789943",
    "stats": "success",
    "pigaiRequestId": "2804371",
    "delEssayCnt": "3"
}
名称类型必填说明
taskIdstring合作方任务id
statsstring执行结果
pigaiRequestIdstring批改网作文号
delEssayCntstring删除完的答题作文

五、删除单篇作文

接口地址:http://url.cn/ouchn/essayDel?sign=xxxx

提交JSON数据

json
{
    "pigaiEssayId": "174018986"
}
{
    "pigaiEssayId": "174018986"
}
名称类型必填说明
pigaiEssayIdstring批改网单篇作文ID

返回说明

json
{ 
    "stats": "success" 
}
{ 
    "stats": "success" 
}
名称类型必填说明
statsstring执行结果

六、回传

是将批改网作文批改后的分数、教师操作等动作 回传到合作方

接口地址: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"
}
名称类型必填说明
openIdstring用户唯一标识
scorestring评分
typestring2为教师评分,1为机器评分
timestring时间
urlstring作文地址
pigaiEssayIdstring批改网单篇作文ID
pigaiRequestIdstring批改网作文号
taskIdstring合作方任务id