protected function fetchURL($URL)
    {
        $cookieHeader = [];
        if ($this->cookie) {
            $cookieHeader[] = 'Cookie: ' . $this->cookie . ';';
        }

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $URL);
        curl_setopt($curl, CURLOPT_HEADER, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $cookieHeader);

        $body = null;
        $result = curl_exec($curl);
        if ($result) {
            $parts = explode("\r\n\r\n", $result, 2);
            $headers = explode("\r\n", $parts[0]);
            if (!$this->cookie) {
                $setCookieString = 'Set-Cookie: ';
                foreach ($headers as $header) {
                    if (strpos($header, $setCookieString) === 0) {
                        $cookieString = substr($header, strlen($setCookieString));
                        $cookieStringParts = explode(';', $cookieString);
                        $this->cookie = $cookieStringParts[0];
                        break;
                    }
                }
            }

            $body = $parts[1];
        }

        return $body;
    }