[Davical-dev] Perl event creator

Andrew McMillan andrew at morphoss.com
Tue May 25 21:34:54 NZST 2010


On Mon, 2010-05-24 at 19:07 +0200, stephane habett roux wrote:
> Hello,
> 
> I'm trying to write a perl script that writes new events to my Davical.

Hi Stephane,

Reading through this, it isn't clear to me whether you set the
content-type to 'text/calendar' on the PUT, which could be your problem
if HTTP::DAV is not doing it for you...

The fact that you don't get an etag back would then be a bug in
DAViCal's handling of non-calendar data - not particularly surprising
since it's only recently that DAViCal has really even tried to handle
non-calendar data.

Cheers,
					Andrew.

> 
> My script goes :
> 
> #!/usr/local/bin/perl
> use HTTP::DAV;
> use Data::Dumper;
> use Date::ICal;
> 
> $dav = HTTP::DAV->new;
> $user = 'usertest';
> $pwd = 'XXXXX';
> $host = 'server';
> $home = "http://$user:$pwd\@$host/caldav.php/$user/home/ 
> <http://$user:$pwd/@$host/caldav.php/$user/home/>";
> $idee = '01234567-4865-5131-5465-568971282CC';
> 
> $dav->credentials( $user, $pwd, "$home" );
> 
> $ds = Date::ICal->new( epoch => time )->ical;
> $de = Date::ICal->new( epoch => time+500 )->ical;
> $dss = $ds;
> $dss =~ s/Z$//;
> $de =~ s/Z$//;
> 
> $str = <<stop;
> BEGIN:VCALENDAR
> PRODID:Data-iCal
> VERSION:2.0
> BEGIN:VEVENT
> DESCRIPTION:YAPH
> CREATED:$ds
> DTEND:$de
> DTSTART:$dss
> DTSTAMP:$ds
> SUMMARY:Perl dav $user
> TRANSP:OPAQUE
> UID:$idee
> END:VEVENT
> END:VCALENDAR
> 
> stop
> $comie = HTTP::DAV::Comms->new();
> $lokk = $dav->get_lockedresourcelist;
> $resource = HTTP::DAV::Resource->new( -uri => "$home/$idee.ics", -Client 
> => $dav, -Comms=>$comie, -LockedResourceList => $lokk);
> $response = $resource->put($str);
> print $response->as_string;
> print "==IS==\n".$dav->propfind("$home/$idee.ics")->as_string;
> 
> 
> And the output goes
> 
> HTTP/1.1 201 Created
> Connection: close
> Date: Thu, 13 May 2010 08:08:21 GMT
> Server: 0.9
> Content-Length: 0
> Content-Type: text/plain; charset="utf-8"
> Client-Date: Thu, 13 May 2010 08:08:21 GMT
> Client-Peer: 127.0.0.1:8008
> Client-Response-Num: 1
> DAV: 1, 2, access-control, calendar-access, calendar-schedule, 
> extended-mkcol, calendar-proxy, bind, calendar-auto-schedule
> X-DAViCal-Version: DAViCal/0.9.9; DB/1.2.8
> X-Powered-By: PHP/5.3.2-1ubuntu4.1
> 
> HTTP::DAV::Resource=HASH(0x8938430)==IS==
> Resource
>    'Url': 
> http://XXXXX:YYYY@HOST/caldav.php/XXXX/home/01234567-4865-5131-5465-568971282CC.ics
>    Properties
>       'creationdate': Wed, 05 May 2010 05:35:49 GMT
>       'creationepoch': 1273037749
>       'current-user-principal': \n <href>/caldav.php/habett/</href>\n
>       'display_date': May 13 10:08
>       'displayname': Habett
>       'getcontentlanguage':
>       'getcontentlength': 275
>       'getcontenttype': text/calendar
>       'getetag':
>       'getlastmodified': Thu, 13 May 2010 08:08:21 GMT
>       'lastmodifieddate': Thu, 13 May 2010 08:08:21 GMT
>       'lastmodifiedepoch': 1273738101
>       'owner': \n <href>/caldav.php/habett/</href>\n
>       'rel_uri': 01234567-4865-5131-5465-568971282CC.ics
>       'resourcetype':
>       'short_props':
>       'supportedlocks': ARRAY(0x8ae1938)
>    '_locks':
> 
> My problem is that the event gets written to the DAV but they don't show 
> up in the calendar as seen from the clients (iPhone, Lightning, iCal).
> 
>  From what I understand I must be missing something and that's why I 
> don't have an ETag and the events don't show up.
> 
> Maybe someone here can help me ?
> 
> All the best,
> 

-- 
------------------------------------------------------------------------
andrew (AT) morphoss (DOT) com                            +64(272)DEBIAN
                 You will be awarded some great honor.
------------------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.morphoss.com/pipermail/davical-dev/attachments/20100525/ad3c7bc4/attachment.pgp>


More information about the Davical-dev mailing list