-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.php
93 lines (59 loc) · 2.44 KB
/
index2.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
<?php
include 'Segment.php';
use App\PruebaTecnica\Entity\Segment;
?>
<html>
<body>
<form action='index2.php' method='POST'>
<input type='hidden' name='sent' value='1' />
<input type='submit' value='Enviar peticion'>
</form>
<?php
if(isset($_REQUEST["sent"]) and $_REQUEST["sent"] == '1'){
$url = 'https://testapi.lleego.com/prueba-tecnica/availability-price';
$options = array(
'uri' => 'http://schemas.xmlsoap.org/soap/envelope/',
'location' => $url,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
'soap_version' => SOAP_1_1,
'cache_wsdl' => WSDL_CACHE_NONE,
'connection_timeout' => 15,
'trace' => 1,
'encoding' => 'UTF-8',
'exceptions' => true,
);
try {
$client = new SoapClient(null,$options);
$client->__setOptions($options);
$header = new SoapHeader($url, 'Authenticate', array('username' => '', 'password' => ''));
$client->__setSoapHeaders($header);
$result = $client->__soapCall('GetData', array());
$response = $client->__getLastResponse();
} catch (Exception $e) {
throw new Exception("Error Processing Request", 1);
}
$xml = simplexml_load_string($response);
$data = $xml->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://www.iata.org/IATA/EDIST/2017.2');
$flights = $data->AirShoppingRS->DataLists->FlightSegmentList->FlightSegment;
$flightList = array();
foreach($flights as $flight){
$segment = new Segment();
$segment->setOriginCode($flight->Departure->AirportCode);
$segment->setOriginName($flight->Departure->AirportName);
$segment->setDestinationCode($flight->Arrival->AirportCode);
$segment->setDestinationName($flight->Arrival->AirportName);
$segment->setStart(new DateTime($flight->Departure->Date . $flight->Departure->Time));
$segment->setEnd(new DateTime($flight->Arrival->Date . $flight->Arrival->Time));
$segment->setTransportNumber($flight->MarketingCarrier->FlightNumber);
$segment->setCompanyCode($flight->MarketingCarrier->AirlineID);
$segment->setCompanyName($flight->MarketingCarrier->Name);
$flightList[] = $segment;
}
print "<pre>";
print_r($flightList);
print "</pre>";
}
?>
</body>
</html>