-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnationalrail.php
42 lines (33 loc) · 1.04 KB
/
nationalrail.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
<?php
function nr_init()
{
global $userdata;
$userdata->nr_client = new SoapClient("https://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx?ver=2017-10-01");
}
function nr_get_board($stn, $aord, $rows = 15, $filterType = null, $filterCrs = null)
{
global $config, $userdata;
$headerParams = array('ns2:TokenValue' => $config['nr_token']);
$soapStruct = new SoapVar ($headerParams, SOAP_ENC_OBJECT);
$header = new SoapHeader('http://thalesgroup.com/RTTI/2010-11-01/ldb/commontypes', 'AccessToken', $soapStruct, false);
$userdata->nr_client->__setSoapHeaders($header);
$args = array('numRows' => $rows, 'crs' => $stn);
$args['timeWindow'] = 120;
try {
if ($filterType !== null)
{
$args['filterType'] = $filterType;
$args['filterCrs'] = $filterCrs;
}
if (strtolower($aord) == 'a')
return $userdata->nr_client->GetArrBoardWithDetails($args);
else
return $userdata->nr_client->GetDepBoardWithDetails($args);
}
catch (SoapFault $e)
{
log_event("SoapFault", 1, "SoapFaul in call to National Rail");
return null;
}
}
?>