function __construct($base_uri, $user, $isCacheCookie = false, $loginParam = [])
{
//Set the base_uri.
$this->base_uri = $base_uri;
//Set the stu_id and password
if (is_array($user) && $user['stu_id'] && $user['stu_pwd']) {
$this->stu_id = $user['stu_id'];
$this->password = $user['stu_pwd'];
} elseif (is_object($user) && $user->stu_id && $user->stu_pwd) {
$this->stu_id = $user->stu_id;
$this->password = $user->stu_pwd;
} else {
Log::error('Login Param error!', $user);
throw new Exception("You must give Lcrawl the user info, like ['stu_id' => '2012xxxxx', 'stu_pwd' => 'xxxx']", 1);
}
$client_param = ['base_uri' => $this->base_uri];
//If this value is true, Lcrawl will cache the cookie jar when logining.
$this->cacheCookie = $isCacheCookie;
//If don't cache cookies, set cookies true, every request use cookie by default way.
if (!$this->cacheCookie) {
$client_param['cookies'] = true;
}
//Set the login post param
if (!empty($loginParam)) {
$this->loginParam = $loginParam;
}
$this->client = new Client($client_param);
}