Created
September 18, 2018 13:54
-
-
Save jhuesser/812af5b08996e4e112334362804d64fc to your computer and use it in GitHub Desktop.
A quick and dirty json parser for opentransportdata.ch to use it with siri shortcuts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$departure = "8573710"; // ID of departure | |
$destination = "8503504"; // ID of destination | |
// use param transportations[] to filter transport type (train, tram, bus, etc. | |
$url = "http://transport.opendata.ch/v1/connections?from=". $departure . " . &to=" . $destination . "&date=" . date('Y-m-d'); | |
$result = json_decode(file_get_contents($url)); | |
// connections[0] seems to be to early, a quick and dirty fix | |
$arrival = $result->connections[1]->to->arrivalTimestamp; | |
$date = strtotime($arrival); | |
echo date("d.m.y H:i",$arrival); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment