PHP code example of rensphilipsen / laravel-ns-api

1. Go to this page and download the library: Download rensphilipsen/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/ */

    

rensphilipsen / laravel-ns-api example snippets


use RensPhilipsen\NSApi\NSApi;

$api = new NSApi();

$stations = $api->getStations(32);

$departures = $api->getDeparturesByStationCode('ut', 32);

$arrivals = $api->getArrivalsByStationCode('ut', 32);

// List disruptions/maintenance/calamities
$disruptions = $api->getDisruptions([
    'type' => 'disruption',
    'isActive' => true,
], 'nl');

// Fetch one disruption by type and id
$singleDisruption = $api->getDisruption('disruption', 'disruption-id', 'en');

// Fetch disruptions for a station
$stationDisruptions = $api->getDisruptionsByStationCode('ut', 'en');

$api->post('some-endpoint', ['field' => 'value']);
$api->postJson('some-endpoint', ['field' => 'value']);
$api->postMultipart('upload', [
    ['name' => 'file', 'contents' => fopen('/path/to/file', 'r')],
]);
bash
php artisan vendor:publish --provider="RensPhilipsen\NSApi\NSApiServiceProvider" --tag="config"