-
Notifications
You must be signed in to change notification settings - Fork 0
/
infoHack.php
117 lines (89 loc) · 2.77 KB
/
infoHack.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
<?php
$country = $_GET['country'];
//echo $country;
//echo "<br/>";
$currency = $_GET['currency'];
//echo $currency;
//echo "<br/>";
$locale = $_GET['locale'];
//echo $locale,"<br/>";
$originplace = $_GET['originplace'];
//echo $originplace,"<br/>";
$destinationplace = $_GET['destinationplace'];
//echo $destinationplace,"<br/>";
$outbounddate = $_GET['outbounddate'];
//echo $outbounddate,"<br/>";
$url ="http://partners.api.skyscanner.net/apiservices/pricing/v1.0";
$data = array( 'apiKey' => 'ah229592831881725379481999349293',
'country' => $country,
'currency' => $currency,
'locale' => $locale,
'originplace' => $originplace,
'destinationplace' => $destinationplace,
'outbounddate' => $outbounddate,
);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$location = $http_response_header[4] . '?apiKey=ah229592831881725379481999349293';
$location = str_replace("Location: ", "", $location);
//var_dump($location);
$json = file_get_contents($location);
$obj = json_decode($json);
// VARIABLES
$price_list = array();
//var_dump($obj);
$currency = $obj->Query->Currency;
$Iti = $obj->Itineraries;
foreach ($Iti as $priOpt) {
foreach ($priOpt as $o) {
foreach ($o as $a) {
$id = $a->Agents[0];
$price = $a->Price;
$price_list[$id] = $price . ' ' .$currency;
}
}
}
$price_list = array_filter($price_list); // delete null values (trash)
foreach ($obj->Agents as $agent ) {
//var_dump($agent->Id);
$idAgent = $agent->Id;
$nameAgent = $agent->Name;
if (array_key_exists($idAgent, $price_list)) {
$price_list[$nameAgent] = $price_list[$idAgent];
unset($price_list[$idAgent]);
}
}
//echo "<pre>" . print_r($price_list,true) . "</pre>";
$keys = array_keys($price_list);
$values = array_values($price_list);
?>
<!DOCTYPE html>
<html>
<head>
<title>Events</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<div id="content">
<ul>
<?php
for($i = 1; $i < count($keys); ++$i)
echo "<li>",$keys[$i],": ",$values[$i],'</li>';
?>
</ul>
</div>
</body>
</html>