LibreY/api.php

24 lines
725 B
PHP
Raw Normal View History

2022-02-17 12:14:56 -08:00
<?php
require "misc/tools.php";
2023-08-21 15:58:09 -07:00
require "misc/search_engine.php";
2023-08-22 16:38:59 -07:00
$opts = load_opts();
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();
}
2022-02-17 12:14:56 -08:00
2023-08-22 16:38:59 -07:00
$results = fetch_search_results($opts, false);
header("Content-Type: application/json");
echo json_encode($results);
2022-09-11 06:54:40 -07:00
?>