forked from Ahwxorg/LibreY
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
29 lines (24 loc) · 872 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
<?php
require "misc/search_engine.php";
require "locale/localization.php";
$opts = load_opts();
if ($opts->disable_api) {
echo "<p>" . TEXTS["api_unavailable"] . "</p>";
die();
}
require "misc/tools.php";
if (!$opts->query) {
echo "<p>Example API request: <a href=\"./api.php?q=gentoo&p=2&t=0\">./api.php?q=gentoo&p=2&t=0</a></p>
<br/>
<p>\"q\" is the keyword</p>
<p>\"p\" is the result page (the first page is 0)</p>
<p>\"t\" is the search type (0=text, 1=image, 2=video, 3=torrent, 4=tor)</p>
<br/>
<p>The results are going to be in JSON format.</p>
<p>The API supports both POST and GET requests.</p>";
die();
}
$results = fetch_search_results($opts, false);
header("Content-Type: application/json");
echo json_encode($results);
?>