librex/api.php

19 lines
613 B
PHP
Raw Normal View History

2022-02-17 17:14:56 -03:00
<?php
require "engines/google.php";
require "engines/bittorrent.php";
if (!isset($_REQUEST["q"]))
{
echo "API usage: <a href=\"https://github.com/hnhx/librex/#api\">https://github.com/hnhx/librex/</a>";
die();
}
2022-02-17 17:14:56 -03:00
$query = $_REQUEST["q"];
$page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0;
$type = isset($_REQUEST["type"]) ? (int) $_REQUEST["type"] : 0;
2022-02-17 17:14:56 -03:00
$results = $type != 3 ? get_google_results($query, $page, $type) : get_bittorrent_results($query);
2022-02-17 17:14:56 -03:00
header('Content-Type: application/json');
echo json_encode($results, JSON_PRETTY_PRINT);
2022-02-17 17:14:56 -03:00
?>