獲取考生成績接口¶
注: 所有接口只針對旗艦會員提供,非旗艦會員無法調(diào)用,所有開放平臺接口默認(rèn)共享10QPS
1、獲取所有考生或者單一考生的考試記錄¶
獲取所有考生或者單一考生的考試記錄:¶
GET https://api.kyexam.com/api/v1/student/queryresults
參數(shù):¶
code=權(quán)限碼&time=當(dāng)前時(shí)間戳&eid=試卷id&loginValues=試卷驗(yàn)證信息&start=0&limit=30
參數(shù)說明:¶
- code 每個(gè)賬戶唯一對應(yīng)的驗(yàn)證碼,string類型,旗艦會員及以上可在系統(tǒng)設(shè)置->開放平臺設(shè)置中獲取。
- time 當(dāng)前時(shí)間戳,例如1638768935。
- start 分頁參數(shù)。
- limit 查詢個(gè)數(shù),最大為100。
- loginValues 如需查詢單個(gè)考生的考試記錄,需配合eid使用。
- eid 如需查詢單個(gè)考生的考試記錄,需配合loginValues使用,詳見示例代碼。
- Authorization 放到請求頭的Token,詳見示例代碼。簡單來說就是:將當(dāng)前時(shí)間戳和您的code拼接起來,進(jìn)行MD5加密而得。
如果操作成功,則返回:¶
{
"data":[
{
"viewResult":"https://api.kyexam.com/transgetresult?tid=xxx\u0026token=xxx", //試卷詳情鏈接,其中 '\u0026' 為 '&' 符號, 需要轉(zhuǎn)碼方可正常使用。
"score":"2",//分?jǐn)?shù)
"passed":"0",//考試是否及格
"status":"1",
"startTime":"1639647217",//考試考試時(shí)間
"endTime":"1639647236",//考試結(jié)束時(shí)間
"sid":"170597",
"loginValue":"n11",//登錄字段
"name":"n11",//考生名字
"eid":"107264"//試卷id
},
{
"viewResult":"https://api.kyexam.com/transgetresult?tid=xxx\u0026token=xxx",
"score":"1",
"passed":"0",
"status":"1",
"startTime":"1639647122",
"endTime":"1639647132",
"sid":"170597",
"loginValue":"n11",
"name":"n11",
"eid":"107264"
}
],
"status":"ok",
"total":1877
}
如果操作失敗,則返回:¶
接口使用示例:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.kyexam.com"
resource := "/api/v1/student/queryresults"
client := &http.Client{}
fullPath := host + resource
req, _ := http.NewRequest(http.MethodGet, fullPath, nil)
time64 := time.Now().UTC().Unix()
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
q := req.URL.Query()
q.Add("code", Code)
q.Add("time", strconv.Itoa(int(time64)))
q.Add("start", "0")
q.Add("limit", "2")
// ↑↑獲取所有考生考試數(shù)據(jù)↑↑
// ↓↓獲取單一考生參與考試的記錄↓↓
// q.Add("loginValues", "n11")
// q.Add("eid", "107264")
q.Add("time", strconv.Itoa(int(time64)))
req.URL.RawQuery = q.Encode()
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
// fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}
2、獲取試卷列表¶
獲取試卷列表¶
GET https://api.kyexam.com/api/v1/student/getexams
參數(shù):¶
code=權(quán)限碼&time=當(dāng)前時(shí)間戳&sid=考生id&gid=組id&catid=分類id&keyword=搜索關(guān)鍵字&userId=用戶id&start=0&limit=30
參數(shù)說明:¶
- code 每個(gè)賬戶唯一對應(yīng)的驗(yàn)證碼,string類型,旗艦會員及以上可在系統(tǒng)設(shè)置->開放平臺設(shè)置中獲取。
- time 當(dāng)前時(shí)間戳,例如1638768935。
- start 分頁參數(shù)。
- limit 查詢個(gè)數(shù),最大為100。
- sid 考生id。
- gid 考生分組id。
- keyword 搜索試卷標(biāo)題關(guān)鍵字
- userId 用戶id
如果操作成功,則返回:¶
{
"data": [
{
"title": "sssssssss",
"description": "你不點(diǎn)進(jìn)來,怎么知道你很厲害",
"status": "永久有效",
"attempts": "無限制",
"available": 1,
"eid": "3504",
"category": "嬰童教育",
"stuTimes": 0,
"totalTimes": 0,
"createTime": "1691473157",
"img": "https://fs.youkaoshi.cn/papercover/company/company_1.png",
"url": "http://10.0.50.159:9874/doexam/aWoeKL89V5.html",
"total_score": 1,
"pass_score": 0.6,
"starttime": 1691473140,
"endtime": 1691473140
},
{
"title": "ccccccssss",
"description": "你不點(diǎn)進(jìn)來,怎么知道你很厲害",
"status": "永久有效",
"attempts": "無限制",
"available": 1,
"eid": "3503",
"category": "嬰童教育",
"stuTimes": 0,
"totalTimes": 1,
"createTime": "1688708778",
"img": "https://fs.youkaoshi.cn/papercover/teacher/teacher_4.png",
"url": "http://10.0.50.159:9874/doexam/EDobq5Lr78.html",
"total_score": -5,
"pass_score": -3,
"starttime": 1688709240,
"endtime": 1688709240
}
],
"status": "ok",
"total": 3
}
如果操作失敗,則返回:¶
接口使用示例:¶
package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
"time"
)
const (
Code = "xxx"
)
func main() {
host := "https://api.kyexam.com"
resource := "/api/v1/student/getexams"
client := &http.Client{}
fullPath := host + resource
req, _ := http.NewRequest(http.MethodGet, fullPath, nil)
time64 := time.Now().UTC().Unix()
ParseToken := fmt.Sprintf("%x", md5.Sum([]byte(strconv.FormatInt(time64, 10)+Code)))
req.Header.Set("Authorization", ParseToken)
q := req.URL.Query()
q.Add("code", Code)
q.Add("time", strconv.Itoa(int(time64)))
q.Add("sid", "1")
q.Add("eid", "2")
q.Add("gid", "3")
q.Add("catid", "4")
q.Add("keyword", "5")
q.Add("userId", "6")
q.Add("start", "0")
q.Add("limit", "30")
req.URL.RawQuery = q.Encode()
resp, err := client.Do(req)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
return
}
// fmt.Println(string(b))
f, _ := os.OpenFile("test.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
f.Write(b)
}