I would like to set my "message of absence" in strato webmail programmatically. For that I open the developer tools (firefox) and I login via strato webmail and set the "message of absence". I get the curl request from the developer console and I rebuild this as a php code:
$myJson = '
{
"actioncmds": [
{
"addresses": [
"mail@domain.de"
],
"days": "7",
"id": "vacation",
"subject": "My Subject",
"text": "My Message"
}
],
"active": true,
"flags": [
"vacation"
],
"id": 5,
"position": 0,
"rulename": "Abwesenheitsbenachrichtigung",
"test": {
"id": "allof",
"tests": [
{
"comparison": "ge",
"datepart": "date",
"datevalue": [
1672272000000
],
"id": "currentdate",
"zone": "+0100"
},
{
"comparison": "le",
"datepart": "date",
"datevalue": [
1672876800000
],
"id": "currentdate",
"zone": "+0100"
}
]
}
}';
function stratoCurl( $url, $type, $parameter ) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array (
'Content-Type: application/x-www-form-urlencoded'
),
);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
return $response;
}
$stratoLogin = stratoCurl("https://webmail.strato.de/appsuite/api/login", "POST", http_build_query(array (
"action" => "login",
"name" => "myUserName",
"password" => "myPassword"
)));
$setMessage = stratoCurl("https://webmail.strato.de/appsuite/api/mailfilter/v2?action=update&session=".$stratoLogin['session'], "PUT", $myJson);
echo '<pre>';
print_r($stratoLogin);
print_r($setMessage);
echo '</pre>';
Result:
Array
(
[session] => MY_SESSION_ID
[user] => myUsername
[user_id] => 9
[context_id] => 52515441
[locale] => de_DE
)
Array
(
[error] => Your session expired. Please login again.
[error_params] => Array
(
[0] => MY_SESSION_ID
)
[categories] => TRY_AGAIN
[category] => 4
[code] => SES-0203
[error_id] => -673980302-22682517
[error_desc] => Your session MY_SESSION_ID expired. Please start a new browser session.
)
Login seems to be successfull, but if I would like to set the message, the session expired?? Any idea?