-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.php
35 lines (34 loc) · 1.04 KB
/
api.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
<?php
/*
//Error Reporting Remove comments when Debugging
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE); // */
require_once("objects/Database.php");
require_once("objects/ApiResource.php");
require_once("objects/Email.php");
require_once("objects/Request.php");
require_once("objects/Response.php");
if(isset($_GET['resource'])) {
$db = new Database();
$request = new Request();
if($_GET['resource'] == 'email') {
$resource = new Email($db, $_GET['resource']);
} else {
$resource = new ApiResource($db, $_GET['resource'], $err);
if($err && $request->type !== 'PUT') {
$response = new Response();
$response->set_status(NOT_FOUND);
$response->error("Resource not found!");
$response->respond();
exit();
}
}
$resource->handle_request($request);
} else {
$response = new Response();
$response->set_status(BAD_REQUEST);
$response->error("No Resource Provided!");
$response->respond();
}
?>