diff --git a/README.md b/README.md index 32af696..7f5739d 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Station validieren - validate() | Name | Typ | Beschreibung | Wird benötigt | | ----- | ------ | --------------------------- | ------------- | -| value | string | Gültiger Name der Station | X | +| value | string | Gültiger Name der Station | X | | id | int | Irgend eine ÖBB Stations ID | | @@ -88,7 +88,7 @@ Verbindung suchen - get() -Details einer Verbindung - getDetails +Details einer Verbindung - getDetails() ----------- **Wissenwertes** @@ -103,8 +103,41 @@ Details einer Verbindung - getDetails | ---- | --- | -------------------------------------------- | ----------------- | | id | int | Index der spezifischen Verbindung. Siehe get | X | - - +**Rückgabewerte** + +| Array | Name | Typ | Beschreibung | Beschreibung | +| ----- | ----------- | --- | ------------ | ------------ | +| start | | | | | +| | station | | | | +| | time | | | | +| | plattform | | | | +| | date | | | | +| | prognose | | | | +| | station | | | | +| end | | | | | +| | time | | | | +| | plattform | | | | +| | date | | | | +| | prognose | | | | +| data | | | | | + +start + station (string) Name der Einstiegs Station + time (string) Abfahrtszeit von der Station + plattform (string) Bahnsteig an der Station + date (string) Abfahrtsdatum + prognose (string) Aktuelle Zeit, if n.a = string(0) +end + station (string) Name der Ausstiegs Station + time (string) Ankunftszeit an der Station + plattform (string) Bahnsteig an der Station + date (string) Ankunftsdatum + prognose (string) Aktuelle Zeit, if n.a = string(0) +data + productName (string) Produktname, z.B RJ, ICE, BUS + productImg (string) Dazugehöriges Bild zum Produkt oebb.at + productUrl (string) Übersicht für die Linie. NULL Bug + duration (string) Fahrzeit der Verbindung diff --git a/oebbApi b/oebbApi_v0.1.php similarity index 93% rename from oebbApi rename to oebbApi_v0.1.php index 9e88227..f8d1ce4 100644 --- a/oebbApi +++ b/oebbApi_v0.1.php @@ -3,12 +3,13 @@ require_once 'phpquery/phpQuery/phpQuery.php'; class oebbApi { - protected $i = 0; protected $data = array(); public function __construct() { session_start(); + $_SESSION["oebbApi"]["get"] = false; + $_SESSION["oebbApi"]["getDetails"] = false; } public function get($departure, $arrival, $amount, $date = null, $time = null, $timeMode = false) { @@ -52,10 +53,14 @@ class oebbApi { } } $_SESSION["oebbApi"] = $this->data; + $_SESSION["oebbApi"]["get"] = true; return $this->data; } public function getCoords() { + if($_SESSION["oebbApi"]["getDetails"] == false) { + return false; + } $details = $_SESSION["oebbApi"]["detail"]; $returnArray = array(); foreach ($details AS $detail) { @@ -131,6 +136,9 @@ class oebbApi { if ($index > count($_SESSION["oebbApi"])) { return false; } + if($_SESSION["oebbApi"]["get"] == false) { + return false; + } $this->loadUrl($_SESSION["oebbApi"][$index]["changesLink"]); @@ -165,6 +173,9 @@ class oebbApi { $startPlattform = pq('.intermediateSection .platform:eq(' . $i . ')')->text(); + $startPrognose = + pq('.intermediateSection .realTime:eq(' . $i . ')')->text(); + $productName = pq('.intermediateSection img.product:eq(' . $j . ')')->attr("alt"); @@ -199,6 +210,9 @@ class oebbApi { $endPlattform = pq('.intermediateSection .platform:eq(' . $i . ')')->text(); + $endPrognose = + pq('.intermediateSection .realTime:eq(' . $i . ')')->text(); + $startStation = $this->trim($startStation); $endStation = $this->trim($endStation); @@ -209,8 +223,11 @@ class oebbApi { $startTime = $this->trim($startTime); $endTime = $this->trim($endTime); - $startPlattform = $this->trim($startPlattform, "\xC2\xA0\n"); - $endPlattform = $this->trim($endPlattform, "\xC2\xA0\n"); + $startPrognose = $this->trim($startPrognose); + $endPrognose = $this->trim($endPrognose); + + $startPlattform = $this->trim($startPlattform); + $endPlattform = $this->trim($endPlattform); $startPlattform = $this->trim($startPlattform); $endPlattform = $this->trim($endPlattform); @@ -230,12 +247,14 @@ class oebbApi { "time" => $startTime, "plattform" => $startPlattform, "date" => $startDate, + "prognose" => $startPrognose, ), "end" => array( "station" => $endStation, "time" => $endTime, "plattform" => $endPlattform, "date" => $endDate, + "prognose" => $endPrognose, ), "data" => array( "productName" => $productName, @@ -252,6 +271,7 @@ class oebbApi { } } $_SESSION["oebbApi"]["detail"] = $changes; + $_SESSION["oebbApi"]["getDetails"] = true; return $changes; } @@ -355,6 +375,7 @@ class oebbApi { "prognose" => $this->getPrognose($pos), "id" => $this->i, "earlier" => $this->getEarlierLink(), + ); return $data; } @@ -421,4 +442,4 @@ class oebbApi { protected function trim($string) { return trim($string, "\xC2\xA0\n\t\r\0\x0B"); } -} +} \ No newline at end of file