On mir first version of the MagicMirror i’ve created a php file witch loads ICLOUD ToDo’s and shows it on the Mirror. Now i’ve updated to MagicMirror² an i have to create a Module witch loads the ToDo’s from the ICLOUD too.
In the fist Version i used CURL to create the request for the ICLOUD, now i have to use something else to realize the request in JavaScript.
Is there anyone who could help me with this?
I’ve tried already NPM REQUEST but i have no Solution for CURLOPT_CUSTOMREQUEST, “REPORT”); and CURLOPT_RETURNTRANSFER, 1);
This was my old php / CURL Request:
// Do CalDAV request to iCloud
$request_body = ‘’;
$request_body .= ‘<c:calendar-query xmlns:d=“DAV:” xmlns:c=“urn:ietf:params:xml:ns:caldav”>’;
$request_body .= ’ <d:prop>‘;
$request_body .= ’ <c:calendar-data>’;
$request_body .= ’ </c:calendar-data>‘;
$request_body .= ’ </d:prop>’;
$request_body .= ’ <c:filter>‘;
$request_body .= ’ <c:comp-filter name=“VCALENDAR”>’;
$request_body .= ’ <c:comp-filter name=“VTODO”>‘;
$request_body .= ’ </c:comp-filter>’;
$request_body .= ’ </c:comp-filter>‘;
$request_body .= ’ </c:filter>’;
$request_body .= ‘</c:calendar-query>’;
$request_body = sprintf($request_body);
$url = ‘https://’.$my_icloud_server.‘-caldav.icloud.com/’.$my_user_id.‘/calendars/’.$my_calendar_id.‘/’;
$c = curl_init($url);
curl_setopt($c, CURLOPT_HTTPHEADER, array( “Depth: 1”,
“Content-Type: text/xml; charset=‘UTF-8’”,
“User-Agent: DAVKit/4.0.1 (730); CalendarStore/4.0.1 (973); iCal/4.0.1 (1374); Mac OS X/10.6.2 (10C540)”
));
curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($c, CURLOPT_USERPWD, $my_icloud_username.“:”.$my_icloud_password);
curl_setopt($c, CURLOPT_CUSTOMREQUEST, “REPORT”);
curl_setopt($c, CURLOPT_POSTFIELDS, $request_body);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$caldav_answer = curl_exec($c);
curl_close($c);
$caldav_answer_object = simplexml_load_string($caldav_answer, ‘SimpleXMLElement’, LIBXML_NOCDATA);
$caldav_answer_array = @json_decode(@json_encode($caldav_answer_object),1);;