in reply to Re^2: Using Perl to add entries in iCal Calendar (cpan secrets)
in thread Using Perl to add entries in iCal Calendar

I don't see a way with the modules in question to connect w/o having an ics file ?

Um, but I thought you already connected, you gave it a url, thats all you had to do to make a connection, the url is the file, it doesn't matter how the webserver stores it on the webserver, the url is what you're getting/editing/updating...

Try this next  print Dumper( $cal->cal ); this should fetch the calendar from the webserver, so you can read it update program for you

#!/usr/bin/perl -- use strict; use warnings; use Data::Dumper (); Main( @ARGV ); exit( 0 ); sub Main { my $user = "test"; my $pass = "test"; my $url = "http://baikal.local/cal.php/principals/test/testshift" +; my $cal = Cal::DAV->new( user => $user, pass => $pass, url => $url, auto_commit => 0, ## don't ->save any changes, we're testing h +ere ); dd( $cal->errors ); dd( $cal->cal ); dd( $cal ); } sub dd { use Data::Dumper; print Data::Dumper->new([@_])->Sortkeys(1) ->Indent(1)->Useqq(1)->Dump . "\n"; }

Then to add entries call add_entries ... to figure out what you need add  print Dumper( make_entry() ); to  Cal-DAV-0.6/t/01basics.t and examine the output (show me)

Also try dave , CalDav is just WebDav which is just HTTP get :)

dave -tmpdir ./i-baikal-tmp -debug 3 -u test -p test "http://baikal.local/cal.php/principals/test/" ... dave> get testshift dave> quit

This should download the testshift database and save it in -tmpdir (or cwd)

Replies are listed 'Best First'.
Re^4: Using Perl to add entries in iCal Calendar (cpan secrets)
by hoschi (Initiate) on May 12, 2014 at 17:56 UTC
    Thanks for the replies and sorry for the late response, unfortunately vacation interrupted my work ;) I tried the code above but it gave errors: Couldn't autofetch calendar: get http://baikal.local/cal.php/principals/test/testshift failed: Not Implemented at /usr/local/share/perl/5.10.1/Cal/DAV.pm line 307. Lines around DAV.pm 307 reads :
    Get the underlying cal object =cut sub cal { my $self = shift; if (!defined $self->{_cal}) { my $ret = $self->get || die "Couldn't autofetch calendar: ".$s +elf->dav->message; } return $self->{_cal}; }
    Also with my script I dumped the complete stuff and found the following errors:
    '_uri' => bless( do{\(my $o = 'http://baikal.local/cal.php/calendars/t +est/testshift')}, 'URI::http' ), + '_headers' => bless( { + 'user-agent' => 'DAV.pm/v0.47', + 'content-length' => 191, + 'host' => 'baikal.local:80' + }, 'HTTP::Headers' ), + '_method' => 'PUT', + '_uri_canonical' => $VAR1->{'_dav'}{'_comms'}{'_last_r +equest'}{'_uri'} + }, 'HTTP::Request' ), '_headers' => + bless( {}, 'HTTP::DAV::Headers' ), '_last_respon +se' => bless( { + '_content' => ' Sabre\\DAV\\Exception\\Conflict PUT is not allowed on non-files. 1.8.7 ', + '_protocol' => 'HTTP/1.1', + '_headers' => bless( { + 'connection' => 'close',
    and
    '_previous' => bless( { + '_protocol' => 'HTTP/1.1', + '_content' => ' Sabre\\DAV\\Exception\\NotAuthenticated No basic authentication headers were found 1.8.7 ', + '_rc' => '401', + '_headers' => bless( { + 'conne +ction' => 'close',
    So there is any issue with not authenticating (properly) or proper handling as put does not seem to be allowed there. For whatever reason. I never dealt with caldav before, but i dont see any problems in the baikal setup itself. I connected my iPad to this and could update entries. Seems not to be an perl script issue, its more like the interaction between "cal" modules and the baikal server. The dave-Part was also not successfull:
    # dave -tmpdir . -debug 3 -u test -p test "http://baikal +.local/cal.php/principals/test/" dave -- DAV Explorer (v2.00) Try "help", or "open http://host.com/dav_enabled_dir/" Setting auth details for baikal.local:80, default to 'test', 'test' new_resource: For http://baikal.local/cal.php/principals/test/, creati +ng new resource Resetting user and password for baikal.local:80, BaikalDAV Using user/pass combo: test test. For BaikalDAV, http://baikal.local/c +al.php/principals/test/ Resetting user and password for baikal.local:80, BaikalDAV Setting auth details for baikal.local:80, BaikalDAV to 'test', 'test' Resetting user and password for baikal.local:80, BaikalDAV ** Connected to http://baikal.local/cal.php/principals/test/ ** dave> get testshift Valid Command: "get" get: http://baikal.local/cal.php/principals/test/testshift -> /var/www +/nmc/shiftplan/testshift new_resource: For http://baikal.local/cal.php/principals/test/testshif +t, creating new resource Resetting user and password for baikal.local:80, BaikalDAV **Server response: Not Found dave> quit Valid Command: "quit" Bye
    There are no *.ics files stored, its somehow virtual. As I am out of ideas I think i try another caldav server and see how this works out.