Пример #1
0
 public function login()
 {
     $form = array('username' => $this->username, 'password' => $this->password);
     try {
         $ret = $this->request($this->loginUrl, $form, array(CURLOPT_REFERER => $this->refererUrl));
     } catch (Exception $e) {
         throw new LoginException();
     }
     $this->cookie = parseInformation('/sulcmiswebpac=([0-9a-zA-Z]+)/', $ret['body']);
     if (!$this->cookie) {
         throw new LoginException();
     }
 }
Пример #2
0
 public function getInfos()
 {
     if (!$this->key || !$this->sessionId) {
         throw new GetInfoException();
     }
     $url = $this->infoUrl . $this->key;
     $ret = $this->request($url, null, array(CURLOPT_COOKIE => 'ASP.NET_SessionId=' . $this->sessionId));
     $body = $ret['body'];
     $infos = array('student_name' => parseInformation('/ctl00_cph_right_inf_xm">([^<]+)</', $body), 'student_number' => parseInformation('/ctl00_cph_right_inf_xh">([^<]+)</', $body));
     $details = explode(' ', parseInformation('/ctl00_cph_right_inf_dw">([^<]+)</', $body));
     $infos['campus'] = $details[0];
     $infos['faculty'] = $details[1];
     // 去掉多余的专业两个字
     $infos['major'] = mb_substr($details[2], 0, -6);
     $infos['grade'] = $details[3];
     $infos['class'] = $details[4];
     return $infos;
 }
Пример #3
0
 public function login()
 {
     $ret = $this->request($this->loginUrl);
     $form = getASPSessionForm($ret['body']);
     $form['ctl00$ContentPlaceHolder1$txtUsername_Lib'] = $this->username;
     $form['ctl00$ContentPlaceHolder1$txtPas_Lib'] = $this->password;
     $form['ctl00$ContentPlaceHolder1$txtlogintype'] = 0;
     $form['ctl00$ContentPlaceHolder1$btnLogin_Lib'] = '登录';
     $ret = $this->request($this->loginUrl, $form);
     $login_error = parseInformation('/ctl00_ContentPlaceHolder1_lblErr_Lib"><font color="#ff0000">([^<]+)</', $ret['body']);
     if ($login_error) {
         throw new LoginException($login_error);
     }
     $this->cookie = parseInformation('/sulcmiswebpac=([0-9a-zA-Z]+)/', $ret['body']);
     if (!$this->cookie) {
         throw new LoginException();
     }
 }