private function sendRequest($method, $args)
 {
     SpotTiming::start(__CLASS__ . '::' . __FUNCTION__);
     $reqarr = array('version' => '1.1', 'method' => $method, 'params' => $args);
     $content = json_encode($reqarr);
     /*
      * Actually perform the HTTP POST
      */
     $svcProvHttp = new Services_Providers_Http(null);
     $svcProvHttp->setUsername($this->_username);
     $svcProvHttp->setPassword($this->_password);
     $svcProvHttp->setMethod('POST');
     $svcProvHttp->setContentType('application/json');
     $svcProvHttp->setRawPostData($content);
     $output = $svcProvHttp->perform($this->_url, null);
     if ($output['successful'] === false) {
         $errorStr = "ERROR: Could not decode json-data for NZBGet method '" . $method . "', " . $output['errorstr'];
         error_log($errorStr);
         throw new Exception($errorStr);
     }
     # if
     $response = json_decode($output['data'], true);
     if (is_array($response) && isset($response['error']) && isset($response['error']['code'])) {
         error_log("NZBGet RPC: Method '" . $method . "', " . $response['error']['message'] . " (" . $response['error']['code'] . ")");
         throw new Exception("NZBGet RPC: Method '" . $method . "', " . $response['error']['message'] . " (" . $response['error']['code'] . ")");
     } elseif (is_array($response) && isset($response['result'])) {
         $response = $response['result'];
     }
     SpotTiming::stop(__CLASS__ . '::' . __FUNCTION__, array($method, $args));
     return $response;
 }
 private function querySabnzbd($request)
 {
     $url = $this->_sabnzbd['url'] . "api?" . $request . '&apikey=' . $this->_sabnzbd['apikey'] . '&output=json';
     $svcProvHttp = new Services_Providers_Http(null);
     $svcProvHttp->setUsername($this->_username);
     $svcProvHttp->setPassword($this->_password);
     $tmpData = $svcProvHttp->perform($url, null);
     return $tmpData['data'];
 }