Compare commits

...

4 commits

Author SHA1 Message Date
Fred fc5e632801 Merge branch 'master' of https://github.com/InternetzTube/oebbApi_v2
Conflicts:
	README.md
2014-01-22 08:47:38 +01:00
Fred 41a9a19187 Update :3 2014-01-22 08:46:07 +01:00
Fred cada5275f1 Delete oebbApi_v0.3-Doku.pdf 2014-01-22 08:39:58 +01:00
Fred dd6df158b1 Update README.md 2014-01-22 08:35:33 +01:00
3 changed files with 70 additions and 6 deletions

View file

@ -1,4 +1,4 @@
Dokumentation für die oebbApi
Dokumentation für die oebbApi - PHP
==========
@ -49,11 +49,17 @@ Station validieren - validate()
**Rückgabewerte**
| Name | Typ | Beschreibung | Wird benötigt |
<<<<<<< HEAD
| ----- | ------ | --------------------------- | ------------- |
| value | string | Gültiger Name der Station | X |
| id | int | Irgend eine ÖBB Stations ID | |
=======
| ----- | ------ | --------------------------- | ------------: |
| value | string | Gültiger Name der Station | Ja |
| id | int | Irgend eine ÖBB Stations ID | Nein |
>>>>>>> cada5275f155639e1f29bab8507bc144f6722a62
***Beispiel***
```php
@ -180,7 +186,7 @@ array(1) {
```
Details einer Verbindung - getDetails
Details einer Verbindung - getDetails()
-----------
@ -199,7 +205,43 @@ Details einer Verbindung - getDetails
| ---- | --- | -------------------------------------------- | ----------------: |
| id | int | Index der spezifischen Verbindung. Siehe get | Ja |
**Rückgabewerte**
<<<<<<< HEAD
| 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
=======
**Rückgabewerte**
@ -284,6 +326,7 @@ array(1) {
Koordinaten einer ganzen Verbindung - getCoords()
-----------
>>>>>>> cada5275f155639e1f29bab8507bc144f6722a62

View file

@ -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");
}
}
}

Binary file not shown.