public static function download_course_backup($hubcourseid, $path) {
        $fp = fopen($path, 'w');

        $curlurl = new \moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/webservice/download.php',
            ['filetype' => self::HUB_BACKUP_FILE_TYPE, 'courseid' => $hubcourseid]);

        // Send an identification token if the site is registered.
        if ($token = registration::get_token()) {
            $curlurl->param('token', $token);
        }

        $ch = curl_init($curlurl->out(false));
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_exec($ch);
        curl_close($ch);
        fclose($fp);
    }