protected function doHttpsPost($hostname, $path, $fields)
    {
        $result = '';
        $fields_string = '';

        //Url encode the string
        foreach($fields as $key => $value)
        {
            if (is_array($value)) {
                if (! empty($value)) {
                    foreach ($value as $k => $v) {
                        $fields_string .= $key . '['. $k .']=' . $v . '&';
                    }
                } else {
                  $fields_string .= $key . '=&';
                }
            } else {
                $fields_string .= $key.'='.$value.'&';
            }
        }

        rtrim($fields_string,'&');

        // cURL or something else
        if(function_exists('curl_init'))
        {
            $curlsession = curl_init();
            curl_setopt($curlsession, CURLOPT_URL, 'https://' . $hostname . $path);
            curl_setopt($curlsession, CURLOPT_POST,count($fields));
            curl_setopt($curlsession, CURLOPT_POSTFIELDS,$fields_string);
            curl_setopt($curlsession, CURLOPT_RETURNTRANSFER,1);
            curl_setopt($curlsession, CURLOPT_SSL_VERIFYHOST,0);
            curl_setopt($curlsession, CURLOPT_SSL_VERIFYPEER,false);

            $result = curl_exec($curlsession);
        }
        else
        {
            // Build a header
            $http_request  = "POST $path HTTP/1.1\r\n";
            $http_request .= "Host: $hostname\r\n";
            $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
            $http_request .= "Content-Length: " . strlen($fields_string) . "\r\n";
            $http_request .= "User-Agent: AreYouAHuman/PHP " . $this->version . "\r\n";
            $http_request .= "Connection: Close\r\n";
            $http_request .= "\r\n";
            $http_request .= $fields_string ."\r\n";

            $result = '';
            $errno = $errstr = "";
            $fs = fsockopen("ssl://" . $hostname, 443, $errno, $errstr, 10);
            if( false == $fs ) {
                error_log('Could not open socket');
            } else {
                fwrite($fs, $http_request);
                while (!feof($fs)) {
                    $result .= fgets($fs, 4096);
                }

                $result = explode("\r\n\r\n", $result, 2);
                $result = $result[1];
            }
        }

        return $result;
    }