-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
68 lines (57 loc) · 1.72 KB
/
index.php
File metadata and controls
68 lines (57 loc) · 1.72 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
<?php
require_once('vendor/bootstrap.php');
$method = $_SERVER['REQUEST_METHOD'];
$response = (object)array(
'ret' => -99,
'message' => 'unknown error',
'error' => (object)array(),
'data' => (object)array()
);
use App\Person;
use App\Mir\Realm;
try
{
switch ($method)
{
case 'GET':
//throw new Exception('you get the page', 1);
$p1 = new Person('def');
$realm = new Realm('first realm');
$data = [
'Person' => $p1->hello(),
'Realm' => $realm->status(),
];
$response->ret = 0;
$response->message = 'you get the page';
$response->data = $data;
break;
case 'POST':
$data =json_decode( file_get_contents('php://input'), true);
print_r($data ? $data : 'no input');
print_r($_POST);
// $timestamp = $data['t'];
// $random = $data['r'];
// $signature = $data['s'];
// $params = $data['params'];
// $sig = new Signature($timestamp, $random);
// $response->ret = 0;
// $response->message = 'you post the page';
// $response->data = array(
// 't' => $timestamp,
// 'r' => $random,
// 's' => $signature,
// 's2' => $sig->digest(),
// 'p' => $params
// );
break;
default:
throw new Exception('unknown request method', -98);
}
}
catch (Exception $e)
{
$response->ret = $e->getCode();
$response->message = $e->getMessage();
}
header("Content-type: application/json; charset=utf8");
echo json_encode($response);