PHP code example of edofre / laravel-ns-api

1. Go to this page and download the library: Download edofre/laravel-ns-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

edofre / laravel-ns-api example snippets


$api = new NsApi();
$stations = $api->getStations();

$api = new NsApi();
$station = new Station('UT', '','','','','','','','','');
$departing_trains = $api->getDepartures($station);

$api = new NsApi();
$station = new Station('ut', '', '', '', '', '', '', '', '', '');
// We want the actual disturbances and not the unplanned disturbances
$disturbances = $api->getDisturbances($station, true , false);

$api = new NsApi();
$from_station = new Station('ZL', '', '', '', '', '', '', '', '', '');
$via_station = new Station('DH', '', '', '', '', '', '', '', '', '');
$to_station = new Station('HT', '', '', '', '', '', '', '', '', '');
$prices = $api->getPrices($from_station, $to_station, $via_station);

php artisan vendor:publish --tag=config