Import ICS to a normal calendar

Hey,

i want import a ics. I would prefer if i could do these with a cronjob.

I have a script for ownCloud, but the pathes doesnt work for Nextcloud.

<?php  
//Hier den Pfad zur Owncloud-Installation einf├╝gen  
define('OWNCLOUD_DIR', '/var/www/virtual/ceeneo/nc.ringzero.de');  
 
require_once(OWNCLOUD_DIR . '/lib/base.php');  
require_once(OWNCLOUD_DIR . '/apps/calendar/lib/import.php');  
require_once(OWNCLOUD_DIR . '/apps/calendar/lib/object.php');
require_once(OWNCLOUD_DIR . '/apps/calendar/lib/calendar.php');
require_once(OWNCLOUD_DIR . '/apps/calendar/lib/app.php');


 
/*  
* Hier die verschiedenen zu importierenden Feeds eintragen  
* userid:      Der Benutzername auf dessen Konto der Kalender importiert werden soll  
* displayname: Der Name des Kalenders in der Owncloud (muss vorher angelegt werden)  
* filename:    Die URL zum ICAL-Feed  
*/  
$Import = array(  	
 
	//Der ├Âffentliche Feiertags-Kalender von iFeiertage
	array(
		"userid" => "ford",
		"displayname" => "Feiertage",
		"filename" => "http://www.ifeiertage.de/bw-.ics"
	),
);
 
foreach($Import AS $cal)
{
	//Nachsehen ob der Kalender auf der Owncloud auch existiert
	try {
		$stmt = OCP\DB::prepare( 'SELECT * FROM `*PREFIX*clndr_calendars` WHERE `userid` = ? AND `displayname` = ?' );
		$result = $stmt->execute(array($cal["userid"], $cal["displayname"]));
		$row = $result->fetchRow();
		$calendar_id = $row['id'];
		if (!$calendar_id) {
			echo "No calendar for userid " . $cal["userid"] . " with displayname '" . $cal["displayname"] . "'";
		}
	} catch (Exception $e) {
		echo "DB exception: " . $e;
	}
 
	// Daten aus dem Feed laden
	$file = file_get_contents($cal["filename"]);
	if ($file === FALSE) {
		echo "Couldn't read file: ".$cal["filename"];
	}
 
	//Import durchf├╝hren
	$import = new OC_Calendar_Import($file);
 
	$import->setUserID($cal["userid"]);
	$import->setTimeZone(OC_Calendar_App::$tz);
	$import->setCalendarID($calendar_id);
	$import->setOverwrite(true);
 
	OC_User::setUserId($cal["userid"]);
 
	try {
		$import->import();
		$count = $import->getCount();
		echo "Imported ".$count." objects in Calendar ".$cal["displayname"]."(".$cal["userid"].")\n";
	} catch (Exception $e) {
		echo "Import failed: " . $e;
	}
}
?>

Can anyone tell me the correct pathes or help me in a other way for the problem?

Thx
Greetings ford

I need to do the same. Did you find a solution?