[Davical-dev] Perl event creator

stephane habett roux habett at habett.org
Tue May 25 05:07:53 NZST 2010


Hello,

I'm trying to write a perl script that writes new events to my Davical.

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,

-- 
Stéphane HAbeTT Roux
Free music for Unfree people : http://habett.net/






More information about the Davical-dev mailing list