further improvements, make more portable
This commit is contained in:
@@ -8,6 +8,12 @@ $search = isset($_GET['search']) ? $_GET['search'] : '';
|
||||
/* cache files */
|
||||
$dbt = "cache-toots.json";
|
||||
|
||||
/* Exit if search empty */
|
||||
if (empty($search)) {
|
||||
out("No proper search given");
|
||||
die();
|
||||
}
|
||||
|
||||
/* MISC FUNCTIONS */
|
||||
function out($data) {
|
||||
error_log("[getcomments.php] " . print_r($data, TRUE));
|
||||
@@ -47,6 +53,7 @@ if (!empty($toots['0']['id'])) {
|
||||
} else {
|
||||
/* if cached toots do not exist, start from oldest toot */
|
||||
$min_id = "0";
|
||||
$min_id_cached = "0";
|
||||
}
|
||||
|
||||
|
||||
@@ -92,11 +99,12 @@ if ($min_id !== $min_id_cached) {
|
||||
/* check if URL from $search exists in $toots */
|
||||
// if multiple exist, take the oldest one (highest array position)
|
||||
$id = array_keys(array_column($toots, 'url'), strtolower($search));
|
||||
if (empty($id)) {
|
||||
out("Blog URL \"$search\" has not been found");
|
||||
die();
|
||||
}
|
||||
$id = $toots[end($id)]['id'];
|
||||
// TODO: graceful exit if no toot exists
|
||||
|
||||
|
||||
$id = "102955148581768112"; // TODO test
|
||||
/* Extract comments and stats from toot */
|
||||
$result = ['comments' => [], 'stats' => ['reblogs' => 0, 'favs' => 0, 'replies' => 0, 'url' => '', 'root' => 0]];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user