-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
82 lines (63 loc) · 2.13 KB
/
example.php
File metadata and controls
82 lines (63 loc) · 2.13 KB
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
<?php
require __DIR__ . '/vendor/autoload.php';
use Vinnia\PackageMapping\Client;
use Vinnia\PackageMapping\SearchParameter;
$env = require __DIR__ . '/env.php';
$client = Client::make($env['web_service_key']);
$data = [];
if ($_POST) {
$res = $client->getTrackList([
new SearchParameter($_POST['tracking_number']),
]);
$data = json_decode((string) $res->getBody(), true);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Package tracker</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>Package tracker</h1>
<?php if ($data): ?>
Tracking <strong><?php echo $_POST['tracking_number']; ?></strong>
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Location</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($data['Tracks'][0]['Activities'] as $act): ?>
<tr>
<td><?php echo $act['Date']; ?> <?php echo $act['Time']; ?></td>
<td><?php echo $act['Location']; ?></td>
<td><?php echo $act['Status']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<hr />
<?php endif; ?>
<form method="post" action="">
<input class="form-control"
type="text"
name="tracking_number"
placeholder="Tracking number" />
<br />
<button class="btn btn-primary">Track</button>
</form>
</div>
</body>
</html>