Owncloud 8.x esportare calendari .ics in automatico

programmazione & dintorni
Rispondi
admin
Site Admin
Messaggi: 205
Iscritto il: dom mar 20, 2016 9:24 pm

Owncloud 8.x esportare calendari .ics in automatico

Messaggio da admin »

Tested on
O.S. Ubuntu 14.04
O.Cloud server ver. 8.1.8

needs:
-composer
-sabre

composer
command line to install composer
php composer-setup.php --install-dir=bin --filename=composer
Now just run php bin/composer in order to run Composer.

to test composer if it is installed:
command line composer
forum2.JPG
forum2.JPG (57.32 KiB) Visto 31173 volte

sabre/vobject
command line to install sabre using composer
composer require sabre/vobject ~4.1

If all went well you should see the following folder
forum3.jpg
forum3.jpg (63.24 KiB) Visto 31173 volte
into vendor directory you have to see:
forum 4.JPG
forum 4.JPG (16.05 KiB) Visto 31173 volte
now you must create this script (source from https://statuscode.ch/2015/06/Combining ... ilability/)
and put it on your server to test before putting it in a cron job to automate

<?php
// Use "composer require sabre/vobject" to get the required libraries
require_once('./vendor/autoload.php');

use Sabre\VObject;

// Configure your data
$remoteHost = 'http://xxx.xxx.xxx.xxx/owncloud';
$calendarName = 'yourcalendarname';
$username = 'usercalendarname';
$password = 'pswusercalendar';

// Get ownCloud calendar
$curl = curl_init($remoteHost . '/remote.php/caldav/calendars/'.$username.'/'.$calendarName.'?export');
curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_VERBOSE, true);
$ics = curl_exec($curl);
curl_close($curl);

// Parse calendar file
$calendar = VObject\Reader::read($ics);

// Replace all SUMMARY fields with a value of "Reserved"
// foreach($calendar->children() as $children) {
// if($children instanceof VObject\Component\VEvent) {
// $children->SUMMARY = 'Reserved';
}
}

// Put the resulting ICS to "destinationdirectory"/public.ics
file_put_contents('Scrivania/TEST/public.ics', $calendar->serialize());
?>


to test you can write in command line:
php scriptaddress scriptname.php

if runs well you can see something like this
forum1.jpg
forum1.jpg (204.67 KiB) Visto 31173 volte
attention: if you return an error like this:
PHP Warning: require_once(./vendor/autoload.php): failed to open stream:
verify you not are writing in command line as "sudo"
Rispondi