I am trying to add a calendar event to Plesk calendar using CalDAV
my code is: I put request using curl
to calendar URL,
I got the exists events so the link not the problem, the problem is creat
my code is:
$uid = "test-12345"; // setting this to an existing uid updates event, a new uid adds event
$url = 'calender_url'.$uid.'.ics'; //http://mail.domain.com/calendars/DOMAIN/USER/Calendar/'.$uid.'.ics'
$userpwd = "user:password";
$description = 'My event description here';
$summary = 'My event title 1';
$tstart = '202006015T000000Z';
$tend = '20200616T000000Z';
$tstamp = gmdate("YmdTHisZ");
$body = "<<<__EOD
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:$tstamp
DTSTART:$tstart
DTEND:$tend
UID:$uid
DESCRIPTION:$description
LOCATION:Office
SUMMARY:$summary
END:VEVENT
END:VCALENDAR
__EOD";
$headers = array(
'Content-Type: text/calendar; charset=utf-8',
'If-None-Match: *',
'Expect: ',
'Content-Length: '.strlen($body),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$exe = curl_exec($ch);
curl_close($ch);
and I got next error
This resource only supports valid iCalendar 2.0 data. Parse error: This parser only supports VCARD and VCALENDAR files
any advice?
thanks in advance.
2
Answers
You should replace
"<<<__EOD
with
<<<__EOD
and
__EOD";
with
__EOD;
PHP_EOL and TRIM() help me:
and watch carefully that the beginning of each line starts with a parameter and not a space or indentation.
And.. now.. we can use (example to use in APP)