The challenge was to get a public transport route, by sending time, date, start and destination address. The problem was solved by using the "Wiener Linien API" (http://akirk.github.com/Wiener-Linien-API/). The PHP-Code sends a XML-request with all details of the appointment and get a XML-respond with the transport connection.
For building a request the PHP-function "buildRequest()" can be used.
The following example illustrates a query from "Seckendorfstrasse 4" to "Wiedner Hauptstr. 8":
$params = array();
$params["outputCoords"] = "WGS84";
$params["from"] = "Seckendorfstrasse 4";
$params["to"] = "Wiedner Hauptstr. 8";
$params["year"] = "2011";
$params["month"] = "12";
$params["day"] = "14";
$params["hour"] = "17";
$params["minute"] = "00";
$params["deparr"] = "arr";
$params["modality"] = "pt";
$params["sourceFrom"] = "gps";
$params["sourceTo"] = "stoplist";
$req = buildRequest("api_get_route", $params);
Afterwards, the XML-request must be sent to the following webservice: http://webservice.qando.at/2.0/webservice.ft.
$response = httpPost("http://webservice.qando.at/2.0/webservice.ft", $req);
Finally, the XML-response must be load into a Document Object Model (DOM). A DOM presents an XML document as a tree-structure, which makes it easy to interpret and evaluate the local public transport route.
$dom = new DOMDocument();
$dom->formatOutput = true;
$dom->preserveWhiteSpace = false;
$dom->loadXML($response);
The complete DOMDocument manual is available on the website: http://php.net/manual/de/class.domdocument.php.
To print out the XML-response of the public transport route, use the following PHP-code:
echo "Response: " .$dom->saveXML(). "";