forked from mauricesvay/sketchfab-portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
32 lines (28 loc) · 781 Bytes
/
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
<?php
require dirname(__FILE__) . '/app/boot.php';
$method = $_SERVER['REQUEST_METHOD'];
$resource = $_GET['resource'];
$action = $_GET['action'];
function respondJson($array) {
header('Content-type: application/json');
echo json_encode($array);
die;
}
if ($method === 'GET') {
if ($resource === 'models') {
respondJson($models);
}
if ($resource === 'profile') {
respondJson($profile);
}
}
if ($method === 'POST') {
if ($resource === 'models' && $action === 'reload') {
$profileResult = importProfile($username, $PROFILE_PATH);
$modelsResult = importModels($username, $MODELS_PATH);
$result = array(
'result' => $profileResult && $modelsResult
);
respondJson($result);
}
}