Open API
登录
URL: https://[site_url]/?q=school-users/api/login
POST参数:id - 学号, pass - 密码
返回:JSON结构字符串,其中uid和token属性将用于其它接口身份验证。
注意:密码错误如果超过10次,则该账号6小时内不能通过此API登录。
PHP示例代码:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://chengjiyun.com/demo/?q=school-users/api/login"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "id=20120101&pass=123"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $output = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($http_code == 200 && $output) { $result = json_decode($output); var_dump($result); } else { echo "http_code: $http_code\n"; echo curl_error($ch); } curl_close ($ch);
示例结果:
object(stdClass)[202] public 'uid' => string '90' (length=2) public 'token' => string '7338c0954acba04b7dd5b8b74dfe2130' (length=32) public 'msg' => string 'login succeed' (length=13)
获取学生考试列表
URL: http://[site_url]/?q=transcripts/api/get-student-exams/[uid]/[token]
其中,uid即token的值应该在登录的接口中获取。
返回:JSON结构字符串,示例结果如下
{"exams": [ {"tid":"58", "name":"2012-2013\u5b66\u5e74\u5ea6\u4e0b\u5b66\u671f\u9ad8\u4e00\u671f\u4e2d\u8003\u8bd5", "short_name":"\u9ad8\u4e00\u4e0b\u671f\u4e2d", "exam_time":"1367078400", "update_time":"1367333382" }, {"tid":"79", "name":"2012\u7ea7\u9ad8\u4e00\u4e0b\u5b66\u671f\u671f\u672b\u8003\u8bd5", "short_name":"\u9ad8\u4e00\u671f\u672b", "exam_time":"1373472000", "update_time":"1377961856" } ] }
获取学生考试个人详细信息
URL: http://[site_url]/?q=transcripts/api/get-student-exam-info/[uid]/[token]/[tid]
其中,uid即token的值应该在登录的接口中获取,tid的值表示考试ID,从“学生考试列表”接口返回结果中获取
返回:JSON结构字符串,示例结果如下
{"table":{"header":["","\u8bed\u6587","\u6570\u5b66","\u82f1\u8bed","\u653f\u6cbb","\u5386\u53f2","\u5730\u7406","\u516d\u79d1"],"rows":[["\u5206\u6570",114,97,116,82,68,88,565],["\u73ed\u5185\u5e73\u5747\u5206",104.5,89.7,101.4,65.7,64.7,81.8,507.8],["\u73ed\u5185\u540d\u6b21","6","11","4","3","17","13","7"],["\u79d1\u5185\u5e73\u5747\u5206",106.6,93.4,104.1,66.9,65.6,82.7,519.9],["\u79d1\u5185\u540d\u6b21","85","193","93","27","192","128","85"]]}}
为方便查看数据结构,下面给出JSON字符串对应的PHP对象结构:
object(stdClass)[230] public 'table' => object(stdClass)[231] public 'header' => array (size=8) 0 => string '' (length=0) 1 => string '语文' (length=6) 2 => string '数学' (length=6) 3 => string '英语' (length=6) 4 => string '政治' (length=6) 5 => string '历史' (length=6) 6 => string '地理' (length=6) 7 => string '六科' (length=6) public 'rows' => array (size=5) 0 => array (size=8) 0 => string '分数' (length=6) 1 => int 114 2 => int 97 3 => int 116 4 => int 82 5 => int 68 6 => int 88 7 => int 565 1 => array (size=8) 0 => string '班内平均分' (length=15) 1 => float 104.5 2 => float 89.7 3 => float 101.4 4 => float 65.7 5 => float 64.7 6 => float 81.8 7 => float 507.8 2 => array (size=8) 0 => string '班内名次' (length=12) 1 => string '6' (length=1) 2 => string '11' (length=2) 3 => string '4' (length=1) 4 => string '3' (length=1) 5 => string '17' (length=2) 6 => string '13' (length=2) 7 => string '7' (length=1) 3 => array (size=8) 0 => string '科内平均分' (length=15) 1 => float 106.6 2 => float 93.4 3 => float 104.1 4 => float 66.9 5 => float 65.6 6 => float 82.7 7 => float 519.9 4 => array (size=8) 0 => string '科内名次' (length=12) 1 => string '85' (length=2) 2 => string '193' (length=3) 3 => string '93' (length=2) 4 => string '27' (length=2) 5 => string '192' (length=3) 6 => string '128' (length=3) 7 => string '85' (length=2)