-
Notifications
You must be signed in to change notification settings - Fork 0
/
restful1.php
53 lines (38 loc) · 879 Bytes
/
restful1.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
<?php
header("Content-Type:application/json");
include 'database1.php';
if(!empty($_GET['data']))
{
$metrics = $_GET['data'];
$response = enigma($metrics);
if(empty($response))
{
deliver_response(200,"metrics not Found",NULL);
}
else
{
deliver_response(200,"metrics Found",$response);
}
}
else
{
deliver_response(400,"No entry Found",NULL);
}
function deliver_response($status,$status_message,$i)
{
global $find;
header("HTTP/1.1 $status $status_message");
$reply['status']=$status;
$reply['status_message']=$status_message;
$json_response=json_encode($reply);
echo "$json_response\n";
for ($row = 0; $row < $i; $row++)
{
$result['data_rate'] = $find[$row]['data_rate'];
$result['Ips'] = $find[$row]['Ips'];
$result['Ipd'] = $find[$row]['Ipd'];
$json_response=json_encode($result);
echo "$json_response\n";
}
}
?>