forked from aldeacms/API-para-Biblia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.bible.php
55 lines (49 loc) · 1.45 KB
/
api.bible.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
<?php
require('class.bible.php');
$Bible = new Bible();
// Variables GET
$fn = $Bible->sanitize($_GET['fn']);
$key = $Bible->sanitize($_GET['key']);
$format = $Bible->sanitize($_GET['format']);
$bible = $Bible->sanitize($_GET['bible']);
$book = $Bible->sanitize($_GET['book']);
$chapter = $Bible->sanitize($_GET['chapter']);
$verse = $Bible->sanitize($_GET['verse']);
$verseFrom = $Bible->sanitize($_GET['versefrom']);
$verseTo = $Bible->sanitize($_GET['verseto']);
// Valid key?
if (!$Bible->validKey($key) || $key == null) {
$responseArray["status"] = "error";
$responseArray["error"] = "Key invalida";
$Bible->print_json($responseArray);
die();
}
// Valid function?
if (!$Bible->validFunction($fn) || $fn == null) {
$responseArray["status"] = "error";
$responseArray["error"] = "Funcion desconocida";
$Bible->print_json($responseArray);
die();
}
switch ($fn) {
case 'books': // All bible books
$responseArray = $Bible->getBooks();
$Bible->print_json($responseArray);
break;
case 'checkverse': // Valid verse?
$responseArray = $Bible->checkVerse($verse);
$Bible->print_json($responseArray);
break;
case 'verse':
$response = $Bible->getVerse($verse);
$Bible->print_json($response);
break;
case 'getFullVerse':
$fullVerse = $Bible->getFullVerse($verse);
echo $fullVerse;
break;
default:
echo 'Error';
break;
}
?>