-
-
Notifications
You must be signed in to change notification settings - Fork 330
Expand file tree
/
Copy pathReadeck.php
More file actions
61 lines (48 loc) · 1.45 KB
/
Readeck.php
File metadata and controls
61 lines (48 loc) · 1.45 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
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace App\SupportedApps\Readeck;
class Readeck extends \App\SupportedApps implements \App\EnhancedApps
{
public $config;
//protected $login_first = true; // Uncomment if api requests need to be authed first
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST
public function __construct()
{
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
}
public function test()
{
$test = parent::appTest($this->url("api/contacts"));
echo $test->status;
}
public function livestats()
{
$status = 'inactive';
$res = parent::execute(
$this->url('api/bookmarks?is_archived=false'),
$this->attrs()
);
$details = json_decode($res->getBody());
$data = [];
if ($details) {
$status = 'active';
$data["bookmarks_count"] = count($details);
}
return parent::getLiveStats($status, $data);
}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
return $api_url;
}
public function attrs()
{
$apikey = $this->config->apikey;
$attrs = [
"headers" => [
"content-type" => "application/json",
"Authorization" => "Bearer " . $apikey,
],
];
return $attrs;
}
}