Skip to content

Guokao Integration API

1. Conventions

Signature

  • Concatenate the POST body $body with the secret key, then MD5 to get sign
  • md5($body + $key)
  • Pass via query string: ?sign=xxxxx
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);

Request

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"
}'

Response Body

json
{
    "data": [],
    "error": 502,
    "error_des": "Reason for failure"
}
{
    "data": [],
    "error": 502,
    "error_des": "Reason for failure"
}
  • error: 0 = success; non-zero = error code

2. Assign Essay Task

Endpoint: http://url.cn/ouchn/request?sign=xxxx

Request JSON

json
{
    "openId": "xxx",
    "taskId": "d2067706",
    "taskTitle": "New English Assignment",
    "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": "New English Assignment",
    "taskRequest": "god",
    "start": "2023-02-08 11:11:15",
    "end": "2023-02-12 11:11:00",
    "userNo": "testt95",
    "taskFatherId": "2067707"
}
FieldTypeRequiredDescription
openIdstringYesUnique user identifier
taskIdstringYesPartner task ID
taskTitlestringYesTask title
taskRequeststringYesTask requirements
startstringYesAnswer start time
endstringYesAnswer deadline
userNostringYesUser employee number
taskFatherIdstringNoTemplate parent task ID for reference assignment

Response

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"
}
FieldTypeRequiredDescription
fatherobjectNoTemplate parent task reference info
taskIdstringYesPartner task ID
openIdstringYesUnique user identifier
pigaiRequestIdstringYesPigai essay ID
urlstringYesEssay settings link
taskUrlstringYesTask answer link

3. Modify Essay Task

Endpoint: http://url.cn/ouchn/requestModify?sign=xxxx

Request JSON

json
{
    "openId": "xxxx",
    "taskId": "ttt",
    "taskTitle": "Blueprint Course Assignment",
    "taskRequest": " ",
    "start": "2023-02-09 17:58:00",
    "end": "2023-02-19 17:54:00"
}
{
    "openId": "xxxx",
    "taskId": "ttt",
    "taskTitle": "Blueprint Course Assignment",
    "taskRequest": " ",
    "start": "2023-02-09 17:58:00",
    "end": "2023-02-19 17:54:00"
}
FieldTypeRequiredDescription
openIdstringYesUnique user identifier
taskIdstringYesPartner task ID
taskTitlestringNoTask title
taskRequeststringNoTask requirements
startstringNoAnswer start time
endstringNoAnswer deadline

Response

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"
}
FieldTypeRequiredDescription
taskIdstringYesPartner task ID
openIdstringYesUnique user identifier
pigaiRequestIdstringYesPigai essay ID
urlstringYesEssay settings link
taskUrlstringYesTask answer link
pigaiRequestTimestringYesModification time

4. Delete Essay Task

Endpoint: http://url.cn/ouchn/requestDel?sign=xxxx

Request JSON

json
{
    "pigaiRequestId": "2804381",
    "taskId": "2067695"
}
{
    "pigaiRequestId": "2804381",
    "taskId": "2067695"
}
FieldTypeRequiredDescription
pigaiRequestIdstringYesPigai essay ID
taskIdstringYesPartner task ID

Response

json
{
    "taskId": "789943",
    "stats": "success",
    "pigaiRequestId": "2804371",
    "delEssayCnt": "3"
}
{
    "taskId": "789943",
    "stats": "success",
    "pigaiRequestId": "2804371",
    "delEssayCnt": "3"
}
FieldTypeRequiredDescription
taskIdstringYesPartner task ID
statsstringYesExecution result
pigaiRequestIdstringYesPigai essay ID
delEssayCntstringYesNumber of student essays deleted

5. Delete Single Essay

Endpoint: http://url.cn/ouchn/essayDel?sign=xxxx

Request JSON

json
{
    "pigaiEssayId": "174018986"
}
{
    "pigaiEssayId": "174018986"
}
FieldTypeRequiredDescription
pigaiEssayIdstringYesPigai single essay ID

Response

json
{ 
    "stats": "success" 
}
{ 
    "stats": "success" 
}
FieldTypeRequiredDescription
statsstringYesExecution result

6. Score Callback

Sends the grading score and teacher actions back to the partner after Pigai processes the essay.

Endpoint: 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"
}
FieldTypeRequiredDescription
openIdstringYesUnique user identifier
scorestringYesScore
typestringYes2 = teacher score, 1 = machine score
timestringYesTimestamp
urlstringYesEssay URL
pigaiEssayIdstringYesPigai single essay ID
pigaiRequestIdstringYesPigai essay ID
taskIdstringYesPartner task ID