private function LingotekSession::login in Lingotek Translation 6
Same name and namespace in other branches
- 7.7 lingotek.session.inc \LingotekSession::login()
- 7.2 lingotek.session.inc \LingotekSession::login()
- 7.3 lingotek.session.inc \LingotekSession::login()
- 7.4 lingotek.session.inc \LingotekSession::login()
- 7.5 lingotek.session.inc \LingotekSession::login()
- 7.6 lingotek.session.inc \LingotekSession::login()
2 calls to LingotekSession::login()
File
- ./
lingotek.session.inc, line 200 - Handles api calls, logging in and logging out of LingoTek
Class
Code
private function login($version = "3.11", $xml = FALSE) {
if ($this->key == "") {
$params = array(
'userLogin' => $this->login_id,
'password' => $this->password,
'version' => $version,
'community' => $this->community,
);
$login = 'login';
}
else {
$arr = array(
'community' => $this->community,
'login_id' => $this->login_id,
'time' => time(),
);
$json_str = json_encode($arr);
$params = array(
"auth_json" => $json_str,
"hmac" => LingotekSession::create_mac($json_str),
"version" => $version,
"returnXML" => $xml,
);
$login = 'keyLogin';
}
$data = $this
->request($login, $params, NULL, FALSE);
$response = json_decode($data->data);
if ($response && $response->results == "success") {
$this->headers = array(
"Cookie" => $data->headers['Set-Cookie'],
);
$this->logged_in = TRUE;
}
else {
$this->logged_in = FALSE;
lingotek_error("Unable to log in", array(
'params' => $params,
'error' => isset($data->error) ? $data->error : "",
'response' => $response,
), 2, WATCHDOG_WARNING);
}
}