private function LingotekSession::login in Lingotek Translation 7.2
Same name and namespace in other branches
- 6 lingotek.session.inc \LingotekSession::login()
- 7.7 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 211 - 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);
if (!isset($data->error) && ($response = json_decode($data->data)) && $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' => isset($response) ? $response : "",
), 2, isset($data->error) ? WATCHDOG_ERROR : WATCHDOG_WARNING);
}
}