2022-02-17 17:14:56 -03:00
|
|
|
<?php
|
2022-03-11 06:04:36 -03:00
|
|
|
require "misc/tools.php";
|
2023-08-21 18:58:09 -04:00
|
|
|
require "misc/search_engine.php";
|
2022-02-24 07:30:15 -03:00
|
|
|
|
2023-08-22 19:38:59 -04:00
|
|
|
$opts = load_opts();
|
|
|
|
|
|
|
|
if (!$opts->query) {
|
2022-10-25 08:02:01 -03:00
|
|
|
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>
|
2022-06-09 05:02:59 -04:00
|
|
|
<br/>
|
|
|
|
<p>\"q\" is the keyword</p>
|
|
|
|
<p>\"p\" is the result page (the first page is 0)</p>
|
2022-12-02 05:41:12 -03:00
|
|
|
<p>\"t\" is the search type (0=text, 1=image, 2=video, 3=torrent, 4=tor)</p>
|
2022-06-09 05:02:59 -04:00
|
|
|
<br/>
|
|
|
|
<p>The results are going to be in JSON format.</p>
|
|
|
|
<p>The API supports both POST and GET requests.</p>";
|
|
|
|
|
2022-02-24 07:30:15 -03:00
|
|
|
die();
|
|
|
|
}
|
2022-02-17 17:14:56 -03:00
|
|
|
|
2023-08-22 19:38:59 -04:00
|
|
|
$results = fetch_search_results($opts, false);
|
2022-06-09 05:02:59 -04:00
|
|
|
header("Content-Type: application/json");
|
2022-11-20 15:00:45 -03:00
|
|
|
echo json_encode($results);
|
2022-09-11 10:54:40 -03:00
|
|
|
?>
|