PHP code example of google / gtfs-realtime-bindings
1. Go to this page and download the library: Download google/gtfs-realtime-bindings 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/ */
google / gtfs-realtime-bindings example snippets
use transit_realtime\FeedMessage;
$data = file_get_contents("URL OF YOUR GTFS-REALTIME SOURCE GOES HERE");
$feed = new FeedMessage();
$feed->parse($data);
foreach ($feed->getEntityList() as $entity) {
if ($entity->hasTripUpdate()) {
error_log("trip: " . $entity->getId());
}
}