コード例 #1
0
ファイル: main.php プロジェクト: tomberthon/pi-train-alerts
<?php

require_once 'vendor/autoload.php';
require_once 'classes/service/StationBoardService.php';
require_once 'classes/service/DisruptionService.php';
$trainListService = new StationBoardService();
$disruptionService = new DisruptionService();
$departureBoard = $trainListService->getDepartingServices("SNS", 20);
$disruption = $disruptionService->getDisruption();
foreach ($departureBoard->nextDepartures as $trainService) {
    foreach ($disruption as $disruptionDetail) {
        $stoppingPoints = $disruptionDetail->stoppingPoints;
        if (array_key_exists($trainService->std, $stoppingPoints) && $stoppingPoints[$trainService->std] == $departureBoard->station) {
            //echo $disruptionDetail->description;
            $trainService->setDisruptionMessage($disruptionDetail->description);
            break;
        }
    }
    //echo $trainService . "\n";
}
コード例 #2
0
<?php

require_once 'vendor/autoload.php';
require_once 'classes/service/StationBoardService.php';
require_once 'classes/converter/TrainServiceConverter.php';
$trainListService = new StationBoardService();
$converter = new TrainServiceConverter();
$redisClient = new Predis\Client(getenv('DB_PORT'));
$targetStationCode = getenv('APP_STATION_CODE');
$departureBoard = $trainListService->getDepartingServices($targetStationCode, 20);
if (is_null($departureBoard)) {
    echo "No Train departures from this station: " . $targetStationCode . "\n";
    exit;
}
$listId = "dep-" . $departureBoard->station;
$redisClient->del($listId);
foreach ($departureBoard->nextDepartures as $trainService) {
    $redisClient->rpush($listId, $converter->toJson($trainService));
    //echo $trainService . "\n";
}