protected function call_service($serviceurl, array $params=array()) {

        $response = (object)array(
            'data' => null,
            'info' => null,
            'status' => null,
        );

        $curl = new curl();

        $response->data = json_decode($curl->get($serviceurl, $params, array(
            'CURLOPT_SSL_VERIFYHOST' => 2,
            'CURLOPT_SSL_VERIFYPEER' => true,
        )));

        $curlerrno = $curl->get_errno();

        if (!empty($curlerrno)) {
            debugging('cURL: Error '.$curlerrno.' when calling '.$serviceurl, DEBUG_DEVELOPER);
            return false;
        }

        $response->info = $curl->get_info();

        if (isset($response->info['ssl_verify_result']) and $response->info['ssl_verify_result'] != 0) {
            debugging('cURL/SSL: Unable to verify remote service response when calling '.$serviceurl, DEBUG_DEVELOPER);
            return false;
        }

        // The first response header with the HTTP status code and reason phrase.
        $response->status = array_shift($curl->response);

        return $response;
    }