-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
30 lines (26 loc) · 818 Bytes
/
index.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
<?php
function error($err, $code = 400) {
http_response_code($code);
if ($err != '')
echo json_encode(['detail' => $err]);
exit();
}
$accounts = [
// ADD YOUR STELLAR ADDRESSES HERE, LIKE THE EXAMPLE BELOW
'wallet*example.com' => [
'stellar_address' => 'wallet*example.com',
'account_id' => '<account_id>',
],
];
header('Access-Control-Allow-Origin: *');
header('Content-type: application/json');
if (!array_key_exists('q', $_GET) || !array_key_exists('type', $_GET))
error('Expected parameters q and type.');
if ($_GET['type'] == 'name') {
$nameLookup = strtolower($_GET['q']);
if (!array_key_exists($nameLookup, $accounts))
error('No record found.', 404);
echo json_encode($accounts[$nameLookup]);
} else {
error('Unsupported type.');
}