getStatus();
$status = json_decode($res->getBody());
if(isset($status->version))
{
echo 'Successfully connected to the API';
}
else if(isset($status->error))
{
echo 'Error: '. $status->error;
}
else
{
echo 'Something went wrong';
}
}
public function executeConfig()
{
$html = '';
$active = 'active';
$html = '
- Wanted: '.$this->getWanted().'
- Activity: '.$this->getQueue().'
';
return json_encode(['status' => $active, 'html' => $html]);
}
public function getStatus()
{
$config = $this->config;
$url = $config->url;
$url = rtrim($url, '/');
$api_url = $url.'/api/system/status?apikey='.$config->apiKey;
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
$res = $client->request('GET', $api_url);
return $res;
}
public function getWanted()
{
$config = $this->config;
$url = $config->url;
$url = rtrim($url, '/');
$api_url = $url.'/api/wanted/missing?apikey='.$config->apiKey.'&pageSize=1';
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
$res = json_decode($client->request('GET', $api_url));
$wanted = $res->totalRecords;
if (empty($wanted)) {
$wanted=0;
}
return $wanted;
}
public function getQueue()
{
$config = $this->config;
$url = $config->url;
$url = rtrim($url, '/');
$api_url = $url.'/api/queue?apikey='.$config->apiKey.'&pageSize=1';
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
$queue = sizeof($client->request('GET', $api_url));
return $queue;
}
}