This library lets you access content from DSBmobile in php.
apt install php7.0-curl
)<?php
include('path/to/dsb_api.php');
// log in
$dsb = new DsbAccount('username', 'password');
// get the url of the first timetable
$timetableUrl = $dsb->getTimetables()->getItem(0)->getUrl();
if ($timetableUrl) {
echo '<a href="https://github.com/irgendwr/dsbmobile-php-api/blob/master/' . $timetableUrl . '">Timetable</a>';
} else {
// an error occurred
echo '<h2>Something went wrong 🙁</h2>';
}
// get all timetables
$timetables = $dsb->getTimetables()->getItems();
// loop through every one of them
foreach ($timetables as $timetable) {
// output their html code
echo $timetable->getHTML();
}
// check if an error occurred
if (count($timetables) == 0) {
echo '<h2>Something went wrong 🙁</h2>';
}
A complete list of methods can be found in the documentation.