forked from zubini/php_icloud_calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
55 lines (36 loc) · 1.31 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* php iCloud Calendar class example
*
* Copyright by Emanuel zuber <[email protected]>
* Version 0.1
*/
// Load ICS parser
require_once('addons/ics-parser/class.iCalReader.php');
// Load iCloud Calendar class
require_once('class.iCloudCalendar.class.php');
// iCloud CalDAV URL looks like:
// https://p02-caldav.icloud.com/12345678/calendars/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/
// https://<SERVER>-caldav.icloud.com/<USER_ID>/calendars/<CALENDAR_ID>/
// Connection settings
$my_icloud_server = 'p02';
$my_user_id = '12345678';
$my_calendar_id= 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
$my_icloud_username = '[email protected]';
$my_icloud_password = 'mysecret';
// iCloud calendar object
$icloud_calendar = new php_icloud_calendar($my_icloud_server, $my_user_id, $my_calendar_id, $my_icloud_username, $my_icloud_password);
// Get iCloud events
$my_range_date_time_from = date("Y-m-d H:i:s", strtotime("-1 week"));
$my_range_date_time_to = date("Y-m-d H:i:s", strtotime("+1 week"));
$my_events = $icloud_calendar->get_events($my_range_date_time_from, $my_range_date_time_to);
// Show iCloud events
print_r($my_events);
// Add iCloud event
/*
$icloud_calendar->add_event(date("Y-m-d 13:30:00"),
date("Y-m-d 16:00:00"),
"My event title",
"My event description",
"My City");
*/