-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteBeaconRESTCall.php
40 lines (33 loc) · 1.18 KB
/
deleteBeaconRESTCall.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
<?php
if (isset($_POST['delete_beacon'])) {
$remove = intval($_POST["remove"]);
// DEBUG
//var_dump($remove);
try {
// Instantiates a new guzzle client.
$client = new GuzzleHttp\Client();
// Sending application/x-www-form-urlencoded POST requests requires
// that you specify the POST fields as an array in the 'form_params'
// request options.
$response = $client->request('POST', 'http://amaca.ga:8080/beacon/delete', [
'form_params' => ['beaconID' => $remove]
]);
$body = $response->getBody();
if($body) {
$done = "<p> <h3> The Beacon with ID $remove is successfully removed!</h2>";
echo $done;
// Refresh the page
header("Refresh: 10; URL=/deleteBeacon");
}
} catch (RequestException $e) {
echo Psr7\str($e->getRequest());
if ($e->hasResponse()) {
echo Psr7\str($e->getResponse());
}
}
}
else {
echo "<br>";
echo "<h5> Waiting for a request...</h5>";
}
?>