forked from linuxserver/Heimdall-Apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkding.php
More file actions
49 lines (40 loc) · 1.1 KB
/
Linkding.php
File metadata and controls
49 lines (40 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace App\SupportedApps\Linkding;
class Linkding extends \App\SupportedApps implements \App\EnhancedApps
{
public $config;
public function __construct() {
}
public function test()
{
$test = parent::appTest($this->url('api/bookmarks?limit=1'), $this->getHeaders());
echo $test->status;
}
public function livestats()
{
$status = 'inactive';
$res = parent::execute($this->url('api/bookmarks?limit=1000'), $this->getHeaders());
$details = json_decode($res->getBody());
$data = [];
if ($details) {
$status = 'active';
$data = [
"bookmark_count" => $details->count,
];
}
return parent::getLiveStats($status, $data);
}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
return $api_url;
}
private function getHeaders()
{
return [
"headers" => [
"Authorization" => "Token " . $this->config->access_token,
],
];
}
}