-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenLDBWS.php
137 lines (99 loc) · 4.46 KB
/
OpenLDBWS.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
class OpenLDBWS
{
private $soapClient = NULL;
private $accessToken;
private $trace;
function __construct($accessToken,$trace=FALSE)
{
$this->accessToken = $accessToken;
$this->trace = $trace;
$soapOptions = array("trace"=>$this->trace,"compression"=>SOAP_COMPRESSION_ACCEPT|SOAP_COMPRESSION_GZIP);
$this->soapClient = new SoapClient("http://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx",$soapOptions);
$soapVar = new SoapVar(array("ns2:TokenValue"=>$this->accessToken),SOAP_ENC_OBJECT);
$soapHeader = new SoapHeader("http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes","AccessToken",$soapVar,FALSE);
$this->soapClient->__setSoapHeaders($soapHeader);
}
private function call($method,$params)
{
try
{
$response = $this->soapClient->$method($params);
}
catch(SoapFault $soapFault)
{
if ($this->trace)
{
$traceOutput["soapFaultMessage"] = $soapFault->getMessage();
$traceOutput["soapClientRequest"] = str_replace($this->accessToken,"",$this->soapClient->__getLastRequest());
$traceOutput["soapClientResponse"] = $this->soapClient->__getLastResponse();
print_r($traceOutput);
}
}
return (isset($response)?$response:FALSE);
}
function StationBoard($method,$numRows,$crs,$filterCrs,$filterType,$timeOffset,$timeWindow)
{
$params["numRows"] = $numRows;
$params["crs"] = $crs;
if ($filterCrs) $params["filterCrs"] = $filterCrs;
if ($filterType) $params["filterType"] = $filterType;
if ($timeOffset) $params["timeOffset"] = $timeOffset;
if ($timeWindow) $params["timeWindow"] = $timeWindow;
return $this->call($method,$params);
}
function DeparturesBoard($method,$crs,$filterList,$timeOffset,$timeWindow)
{
$params["crs"] = $crs;
$params["filterList"] = $filterList;
if ($timeOffset) $params["timeOffset"] = $timeOffset;
if ($timeWindow) $params["timeWindow"] = $timeWindow;
return $this->call($method,$params);
}
function GetDepartureBoard($numRows,$crs,$filterCrs="",$filterType="",$timeOffset="",$timeWindow="")
{
return $this->StationBoard("GetDepartureBoard",$numRows,$crs,$filterCrs,$filterType,$timeOffset,$timeWindow);
}
function GetDepBoardWithDetails($numRows,$crs,$filterCrs="",$filterType="",$timeOffset="",$timeWindow="")
{
return $this->StationBoard("GetDepBoardWithDetails",$numRows,$crs,$filterCrs,$filterType,$timeOffset,$timeWindow);
}
function GetArrivalBoard($numRows,$crs,$filterCrs="",$filterType="",$timeOffset="",$timeWindow="")
{
return $this->StationBoard("GetArrivalBoard",$numRows,$crs,$filterCrs,$filterType,$timeOffset,$timeWindow);
}
function GetArrBoardWithDetails($numRows,$crs,$filterCrs="",$filterType="",$timeOffset="",$timeWindow="")
{
return $this->StationBoard("GetArrBoardWithDetails",$numRows,$crs,$filterCrs,$filterType,$timeOffset,$timeWindow);
}
function GetArrivalDepartureBoard($numRows,$crs,$filterCrs="",$filterType="",$timeOffset="",$timeWindow="")
{
return $this->StationBoard("GetArrivalDepartureBoard",$numRows,$crs,$filterCrs,$filterType,$timeOffset,$timeWindow);
}
function GetArrDepBoardWithDetails($numRows,$crs,$filterCrs="",$filterType="",$timeOffset="",$timeWindow="")
{
return $this->StationBoard("GetArrDepBoardWithDetails",$numRows,$crs,$filterCrs,$filterType,$timeOffset,$timeWindow);
}
function GetNextDepartures($crs,$filterList,$timeOffset="",$timeWindow="")
{
return $this->DeparturesBoard("GetNextDepartures",$crs,$filterList,$timeOffset,$timeWindow);
}
function GetNextDeparturesWithDetails($crs,$filterList,$timeOffset="",$timeWindow="")
{
return $this->DeparturesBoard("GetNextDeparturesWithDetails",$crs,$filterList,$timeOffset,$timeWindow);
}
function GetFastestDepartures($crs,$filterList,$timeOffset="",$timeWindow="")
{
return $this->DeparturesBoard("GetFastestDepartures",$crs,$filterList,$timeOffset,$timeWindow);
}
function GetFastestDeparturesWithDetails($crs,$filterList,$timeOffset="",$timeWindow="")
{
return $this->DeparturesBoard("GetFastestDeparturesWithDetails",$crs,$filterList,$timeOffset,$timeWindow);
}
function GetServiceDetails($serviceID)
{
$params["serviceID"] = $serviceID;
return $this->call("GetServiceDetails",$params);
}
}
?>