I use baikal. I like it. It is relatively simple to use actually, you just got to get the hang of it. So you need to make time to mess around with it, get your trial and error on...
I think most of the project has been archived because the main dev @evert has moved on. But he created a great CALDAV/CARDDAV. And @ByteHamster still looks over it and I believe has contributed, or at least provides help on git to answer Q's as much as he can. There is no traditional REST with JSON payload, but once you understand the XML you can break it down and build a JSON response. I did it, and seems to work well. I just can't find it right now..
I didn't get a chance to venture into CARDDAV, but once baikal is installed as a sub domain, or however you want to do it, sub domain is recommended, you can do calls to the endpoint you need via curl in PHP to receive an XML response.
Take note, this is a mess and is out of context. I've also never had time to rewrite for efficiency or make it pretty, sorry. But hopefully it gives you a lead. Practice your calls from the terminal with curl
use Sabre\VObject; //this is to use the vobjects
use Sabre\DAV\Client;
require_once( str_replace( 'classes', '', __DIR__ . '/baikal/vendor/autoload.php') );
class ical{
public function getVTODOS($model, $cnx){
/*
* getVEVENTS and getVTODOS are practically the same, deprecate this to make only one call dumbass
*/
//array(3) { ["datestamp"]=> string(10) "2021-07-27" ["start"]=> string(8) "20210401" ["end"]=> string(9) "20220731 " }
$ical = new ical;
$accounts = $ical->authenticate($cnx);
if(!empty($accounts['accounts'])){
if(isset($model['start']) && isset($model['end'])){
$start = date('Ymd', strtotime($model['start'])) . 'T000000Z';
$end = date('Ymd', strtotime($model['end'])) . 'T000000Z';
}else{
// use $date and strtotime() to get last year and next year, date format ex. 20171214T000000Z
// date('Ymd', strtotime($datestamp . '- 1 year')); //ex. present year 2017
$start = date('Ymd', strtotime($datestamp . '- 1 year')) . 'T000000Z';//ex. 20161213T000000Z
$end = date('Ymd', strtotime($datestamp . '+ 1 year')) . 'T000000Z';//ex. 20181213T000000Z
}
$request = '<?xml version="1.0" encoding="UTF-8" ?>
<L:calendar-query xmlns:L="urn:ietf:params:xml:ns:caldav">
<D:prop xmlns:D="DAV:">
<D:getcontenttype/>
<D:resourcetype/>
<D:getetag/>
<L:calendar-data/>
</D:prop>
<L:filter>
<L:comp-filter name="VCALENDAR"><L:comp-filter name="VTODO">
<L:time-range start="'.$start.'" end="'.$end.'"/>
</L:comp-filter>
</L:comp-filter>
</L:filter>
</L:calendar-query>';
$headers = array(
'Content-Type: text/xml; charset=utf-8',
'Depth:1',
);
//$url = 'https://cal.domain.ca/cal.php/calendars/' . $user['caldav-username'] . '/default/';
$url = CALDAV . '/cal.php/calendars/' . $user['caldav-username'] . '/default/';
$userpwd = $user['caldav-username'] . ':' . $user['caldav-password'];
$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, 'REPORT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
return curl_exec($ch);
curl_close($ch);
}//public function getVTODOS($model, $cnx, $datestamp)
}else{
$response = null;
}//if(!empty($accounts['accounts']))
}//ical