public function LingotekSession::request in Lingotek Translation 6
Same name and namespace in other branches
- 7.7 lingotek.session.inc \LingotekSession::request()
- 7.2 lingotek.session.inc \LingotekSession::request()
- 7.3 lingotek.session.inc \LingotekSession::request()
- 7.4 lingotek.session.inc \LingotekSession::request()
- 7.5 lingotek.session.inc \LingotekSession::request()
- 7.6 lingotek.session.inc \LingotekSession::request()
3 calls to LingotekSession::request()
File
- ./
lingotek.session.inc, line 82 - Handles api calls, logging in and logging out of LingoTek
Class
Code
public function request($api, $params = NULL, $data = NULL, $returnJson = TRUE) {
if (!$this
->isLoggedIn() && !in_array($api, $this->sessionless)) {
$this
->login();
}
$query = "";
if (isset($params)) {
$query = http_build_query($params, '', '&');
}
$this->headers["Content-Type"] = "application/x-www-form-urlencoded;";
$response = drupal_http_request($this->url . "/" . $api, $this->headers, 'POST', $query);
if ($returnJson) {
$json = json_decode($response->data);
if ($json->results != "success") {
lingotek_error('API ' . $api . ' FAILED', array(
'params' => $params,
'response' => $json,
), 1);
}
return $json;
}
else {
return $response;
}
}