Ich hab ein Ticket geöffnet.
Ich bin nun auf die bei Github verlinkte Seite gekommen.
https://webuntis.noim.me/
<?php
// WebUntis API Aufruf für IP-Symcon
// Konfiguration
$school = 'SChule';
$username = '1';
$password = '';
$server = 'kephiso.webuntis.com';
// API-Endpunkt
$url = "https://{$server}/WebUntis/jsonrpc.do?school=" . urlencode($school);
// Funktion zum Senden von API-Anfragen
function sendRequest($url, $method, $params, $sessionId = null) {
$data = array(
'id' => 'ID',
'method' => $method,
'params' => $params,
'jsonrpc' => '2.0'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
if ($sessionId) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Cookie: JSESSIONID=' . $sessionId
));
}
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return array(
'response' => json_decode($response, true),
'httpCode' => $httpCode
);
}
// Login
$loginResult = sendRequest($url, 'authenticate', array(
'user' => $username,
'password' => $password,
'client' => 'IP-Symcon'
));
if (isset($loginResult['response']['error'])) {
die('Login-Fehler: ' . $loginResult['response']['error']['message'] . ' (HTTP Code: ' . $loginResult['httpCode'] . ')');
}
$sessionId = $loginResult['response']['result']['sessionId'];
$personType = $loginResult['response']['result']['personType'];
$personId = $loginResult['response']['result']['personId'];
echo "Login erfolgreich. Person ID: $personId, Typ: $personType\n";
// Hole Stundenplan für heute
$today = date('Ymd');
$timetableResult = sendRequest($url, 'getTimegrid', array(
'options' => array(
'element' => array(
'id' => $personId,
'type' => $personType
),
'startDate' => $today,
'endDate' => $today,
'showInfo' => true,
'showSubstText' => true,
'showLsText' => true,
'showLsNumber' => true,
'showStudentgroup' => true
)
), $sessionId);
if (isset($timetableResult['response']['error'])) {
die('Fehler beim Abrufen des Stundenplans: ' . $timetableResult['response']['error']['message'] . ' (HTTP Code: ' . $timetableResult['httpCode'] . ')');
}
// Verarbeite den Stundenplan
$timetable = array();
foreach ($timetableResult['response']['result'] as $lesson) {
$startTime = substr($lesson['startTime'], 0, 2) . ':' . substr($lesson['startTime'], 2);
$endTime = substr($lesson['endTime'], 0, 2) . ':' . substr($lesson['endTime'], 2);
$subject = isset($lesson['su'][0]['name']) ? $lesson['su'][0]['name'] : 'N/A';
$teacher = isset($lesson['te'][0]['name']) ? $lesson['te'][0]['name'] : 'N/A';
$room = isset($lesson['ro'][0]['name']) ? $lesson['ro'][0]['name'] : 'N/A';
$timetable[] = array(
'Zeit' => "{$startTime} - {$endTime}",
'Fach' => $subject,
'Lehrer' => $teacher,
'Raum' => $room
);
}
// Erstelle HTML-Tabelle für den Stundenplan
$html = '<table border="1" style="border-collapse: collapse; width: 100%;">
<tr style="background-color: #f2f2f2;">
<th style="padding: 10px; text-align: left;">Zeit</th>
<th style="padding: 10px; text-align: left;">Fach</th>
<th style="padding: 10px; text-align: left;">Lehrer</th>
<th style="padding: 10px; text-align: left;">Raum</th>
</tr>';
foreach ($timetable as $lesson) {
$html .= "<tr>
<td style='padding: 8px; border: 1px solid #ddd;'>{$lesson['Zeit']}</td>
<td style='padding: 8px; border: 1px solid #ddd;'>{$lesson['Fach']}</td>
<td style='padding: 8px; border: 1px solid #ddd;'>{$lesson['Lehrer']}</td>
<td style='padding: 8px; border: 1px solid #ddd;'>{$lesson['Raum']}</td>
</tr>";
}
$html .= '</table>';
// Schreibe den HTML-Stundenplan in die IP-Symcon-Variable mit ID 33406
SetValue(33406, $html);
echo "Stundenplan für heute wurde als HTML in Variable 33406 gespeichert.";
// Logout
sendRequest($url, 'logout', array(), $sessionId);
?>
Es kommt sowohl bei gettimetable,gettimetablefortoday,gettimegrid diese Meldung:
Login erfolgreich. Person ID: 4639, Typ: 5
Fehler beim Abrufen des Stundenplans: no right for timetable (HTTP Code: 200)
Mal schauen…