ajout heimdall
This commit is contained in:
89
heimdall/config/www/SupportedApps/FreshRSS/FreshRSS.php
Executable file
89
heimdall/config/www/SupportedApps/FreshRSS/FreshRSS.php
Executable file
@@ -0,0 +1,89 @@
|
||||
<?php namespace App\SupportedApps\FreshRSS;
|
||||
|
||||
class FreshRSS extends \App\SupportedApps implements \App\EnhancedApps
|
||||
{
|
||||
public $config;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
private $clientVars = [
|
||||
"http_errors" => false,
|
||||
"timeout" => 15,
|
||||
"connect_timeout" => 15,
|
||||
"verify" => false,
|
||||
];
|
||||
|
||||
public function test()
|
||||
{
|
||||
$attrs = [
|
||||
"body" => "api_key=" . $this->getApiKey(),
|
||||
"headers" => [
|
||||
"Content-Type" => "application/x-www-form-urlencoded",
|
||||
],
|
||||
];
|
||||
|
||||
$res = parent::execute(
|
||||
$this->url("api/fever.php?api"),
|
||||
$attrs,
|
||||
$this->clientVars,
|
||||
"POST"
|
||||
);
|
||||
|
||||
if ($res->getStatusCode() == 200) {
|
||||
$data = json_decode($res->getBody());
|
||||
if ($data != null && $data->auth === 1) {
|
||||
echo "Welcome " .
|
||||
$this->config->username .
|
||||
", you are connected to API v" .
|
||||
$data->api_version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = "inactive";
|
||||
$data = [];
|
||||
|
||||
$attrs = [
|
||||
"body" => "api_key=" . $this->getApiKey(),
|
||||
"headers" => [
|
||||
"Content-Type" => "application/x-www-form-urlencoded",
|
||||
],
|
||||
];
|
||||
|
||||
$res = parent::execute(
|
||||
$this->url("api/fever.php?api&unread_item_ids"),
|
||||
$attrs,
|
||||
$this->clientVars,
|
||||
"POST"
|
||||
);
|
||||
if ($res->getStatusCode() == 200) {
|
||||
$body = json_decode($res->getBody());
|
||||
if ($body->auth === 1) {
|
||||
if ($body->unread_item_ids != "") {
|
||||
$data["unread"] = count(
|
||||
explode(",", $body->unread_item_ids)
|
||||
);
|
||||
} else {
|
||||
$data["unread"] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent::getLiveStats($status, $data);
|
||||
}
|
||||
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
|
||||
return $api_url;
|
||||
}
|
||||
|
||||
public function getApiKey()
|
||||
{
|
||||
return md5($this->config->username . ":" . $this->config->apikey);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user