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