mirror of
https://git.bakhai.co.in/FbIN/LibreY.git
synced 2025-11-07 04:51:30 +05:30
commit
c9898cf261
95 changed files with 5217 additions and 0 deletions
32
engines/special/definition.php
Normal file
32
engines/special/definition.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
class DefinitionRequest extends EngineRequest {
|
||||
|
||||
public function get_request_url() {
|
||||
$split_query = explode(" ", $this->query);
|
||||
$reversed_split_q = array_reverse($split_query);
|
||||
$word_to_define = $reversed_split_q[1] == "define" ? $reversed_split_q[0] : $reversed_split_q[1];
|
||||
return "https://api.dictionaryapi.dev/api/v2/entries/en/$word_to_define";
|
||||
}
|
||||
|
||||
public function parse_results($response) {
|
||||
$json_response = json_decode($response, true);
|
||||
|
||||
if (!$json_response)
|
||||
return array();
|
||||
|
||||
if (!array_key_exists("title", $json_response))
|
||||
{
|
||||
$definition = $json_response[0]["meanings"][0]["definitions"][0]["definition"];
|
||||
|
||||
$source = "https://dictionaryapi.dev";
|
||||
return array(
|
||||
"special_response" => array(
|
||||
"response" => htmlspecialchars($definition),
|
||||
"source" => $source
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue