edit request method
This commit is contained in:
parent
9bf063c7bd
commit
e06b571e7d
1 changed files with 5 additions and 4 deletions
|
@ -75,25 +75,26 @@ class Server_Manager_Mailcow extends Server_Manager
|
||||||
{
|
{
|
||||||
$host = 'https://' . $this->_config['host'] . '/api/v1/';
|
$host = 'https://' . $this->_config['host'] . '/api/v1/';
|
||||||
|
|
||||||
// Server credentials
|
// Server headers
|
||||||
$headers['X-API-Key'] = $this->_config['accesshash'];
|
$headers['X-API-Key'] = $this->_config['accesshash'];
|
||||||
|
$headers['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
// Send POST query
|
// Send POST query
|
||||||
$client = $this->getHttpClient()->withOptions([
|
$client = $this->getHttpClient()->withOptions([
|
||||||
'verify_peer' => false,
|
'verify_peer' => false,
|
||||||
'verify_host' => false,
|
'verify_host' => false,
|
||||||
'timeout' => 10
|
'timeout' => 25
|
||||||
]);
|
]);
|
||||||
$response = $client->request($type, $host . $path, [
|
$response = $client->request($type, $host . $path, [
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
'body' => $params != [] ? $params : null
|
...$params
|
||||||
]);
|
]);
|
||||||
$result = $response->getContent();
|
$result = $response->getContent();
|
||||||
|
|
||||||
if (str_contains($result, 'authentication failed')) {
|
if (str_contains($result, 'authentication failed')) {
|
||||||
throw new Server_Exception('Failed to connect to the :type: server. Please verify your credentials and configuration', [':type:' => 'Mailcow']);
|
throw new Server_Exception('Failed to connect to the :type: server. Please verify your credentials and configuration', [':type:' => 'Mailcow']);
|
||||||
} elseif (str_contains($result, 'error')) {
|
} elseif (str_contains($result, 'error')) {
|
||||||
error_log("Mailcow returned error $result for the " . $params['cmd'] . 'command');
|
error_log("Mailcow returned error $result for the " . $path . ' command');]
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
Loading…
Reference in a new issue