API Client
Retrieving calendar events

Calendar class provides methods to fetch a list of calendar events.

You can get an instance of Calendar class by calling Client::calendar() method:

$token = stored_access_token(); // previously obtained access token
$auth = new Authentication\OAuth($token);
$client = new APIClient\Client('https://demo.1crmcloud.com/api.php', $auth);
$calendar = $client->calendar();

Retrieving calendar events

To retrieve a list of calendar events within specified dates range, use Calendar::events() method, passing start and end dates. The dates must be strings conforming to Y-m-d H:i:s format as used by PHP date function. Use GMT timezone.

$calendar = $client->calendar();
$result = $calendar->events('2018-03-26 00:00:00', '2018-03-27 23:59:59');
echo json_encode($result, JSON_PRETTY_PRINT);
1 [
2  {
3  "name": "Bad time, will call back",
4  "date_start": "2018-03-26 06:45:00",
5  "date_due": null,
6  "location": null,
7  "id": "3d5398a2-f209-a5d2-9cdb-5a8fc2d22297",
8  "type": "Call"
9  },
10  {
11  "name": "Follow-up on proposal",
12  "date_start": "2018-03-27 08:30:00",
13  "date_due": null,
14  "location": null,
15  "id": "e73a50c1-6687-8a95-364d-5a8fc241ba18",
16  "type": "Meeting"
17  }
18 ]

You can limit returned event types by passing third argument to Calendar::events() method, with an array of desired event types. Supported types are Call, Meeting, Task, ProjectTask

$calendar = $client->calendar();
$result = $calendar->events('2018-03-26 00:00:00', '2018-03-27 23:59:59', ['Call']);
echo json_encode($result, JSON_PRETTY_PRINT);
1 [
2  {
3  "name": "Bad time, will call back",
4  "date_start": "2018-03-26 06:45:00",
5  "date_due": null,
6  "location": null,
7  "id": "3d5398a2-f209-a5d2-9cdb-5a8fc2d22297",
8  "type": "Call"
9  }
10 ]