/dsbmobile-php-api

This library lets you access content from DSBmobile in php.

Primary LanguagePHPMIT LicenseMIT

dsbmobile-php-api

Documentation Travis

This library lets you access content from DSBmobile in php.

Requirements

  • PHP 5.4.x or newer
  • curl module for php (on debian/ubuntu: apt install php7.0-curl)

Example

Basic example

<?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="' . $timetableUrl . '">Timetable</a>';
} else {
    // an error occurred
    echo '<h2>Something went wrong 🙁</h2>';
}

Display every timetable

// 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.