-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.php
58 lines (50 loc) · 1001 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
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
<?php
/**
* Instant API executable
*
* This is the file through which requests to Instant API should be made via HTTP.
*
* LICENSE: MIT
*
* @author Waldo Jaquith <waldo@jaquith.org>
* @copyright 2014 Waldo Jaquith
* @license http://opensource.org/licenses/MIT
* @link https://github.com/waldoj/instant-api/
*
*/
/*
* Include the settings.
*/
require('settings.inc.php');
/*
* Include the Instant API library.
*/
require('class.InstantAPI.php');
/*
* All output will be as JSON.
*/
header('Content-Type: application/json');
/*
* Require that an ID be present in the request.
*/
if (!isset($_GET['id']))
{
json_error('No ID provided.');
die();
}
/*
* Create a new instance of Instant API.
*/
$server = new InstantAPI();
/*
* If the requested ID doesn't exist, return a 404.
*/
if (!isset($server->data->{$server->id}))
{
json_error('ID not found.', '404 Not Found');
die();
}
/*
* Return the record to the client.
*/
echo json_encode($server->data->{$server->id});