2017 © Pedro Peláez
 

library cronofy

image

cronofy/cronofy

  • Sunday, July 29, 2018
  • by gshutler
  • Repository
  • 8 Watchers
  • 14 Stars
  • 7,729 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 2 Open issues
  • 42 Versions
  • 56 % Grown

The README.md

Cronofy

Cronofy - one API for all the calendars (Google, iCloud, Exchange, Office 365, Outlook.com) php CI, (*1)

Sample Application

To see this API wrapper in action see our sample app here, (*2)

Usage

Note: if upgrading from a v0.x.x version to v1.0.0, please read the migration guide, (*3)

In order to use the Cronofy API you will need to create a developer account., (*4)

From there you can use your Calendar Sandbox to access your own calendars, or you can create an OAuth application to obtain an OAuth client_id and client_secret to be able to use the full API., (*5)

Authorization

API documentation, (*6)

Generate a link for a user to grant access to their calendars:, (*7)

$redirect_uri = "http://yoursite.dev/oauth2/callback";

$cronofy = new Cronofy\Cronofy(["client_id" => "CRONOFY_CLIENT_ID"]);
$params = [
  'redirect_uri' => $redirect_uri,
  'scope' => ['read_account','list_calendars','read_events','create_event','delete_event']
];
$auth = $cronofy->getAuthorizationURL($params);

The redirect URI is a page on your website that will handle the OAuth 2.0 callback and receive a code parameter. You can then use that code to retrieve an OAuth token granting access to the user's Cronofy account:, (*8)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET"
]);

$params = [
  'redirect_uri' => $redirect_uri,
  'code' => $code
];

$result = $cronofy->requestToken($params);

// Retrieve credentials value
$accessToken = $cronofy->accessToken;
$refreshToken = $cronofy->refreshToken;
$expiresIn = $cronofy->expiresIn;

You should save the response's AccessToken and RefreshToken for later use., (*9)

Note that the exact same redirect URI must be passed to both methods for access to be granted., (*10)

$result will be true for a successful request; otherwise, it will be an error code. Please reference our documentation for possible error code., (*11)

Refresh Access Token

Refresh an access token for an account:, (*12)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "grant_type" => "refresh_token",
  "refresh_token" => "YOUR_REFRESH_TOKEN"
]);

$new_access_token = $cronofy->refreshToken();

List calendars

API documentation, (*13)

Get a list of all the user's calendars:, (*14)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$calendar = $cronofy->listCalendars();

Read events

API documentation, (*15)

Get a list of all the user's events:, (*16)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'tzid' => 'Etc/UTC'
];

$events = $cronofy->readEvents($params);

foreach($events->each() as $event){
  // process event
}

Create or update events

API documentation, (*17)

To create or update an event in the user's calendar:, (*18)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'calendar_id' => 'CalendarID',
  'event_id' => 'event_test_12345679',
  'summary' => 'test event 2',
  'description' => 'some event data here',
  'start' => '2015-12-07T09:00:00Z',
  'end' => '2015-12-08T10:00:00Z'
];
$new_event = $cronofy->upsertEvent($params);

Delete events

API documentation, (*19)

To delete an event from user's calendar:, (*20)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'calendar_id' => 'CalendarID',
  'event_id' => 'EventID'
];

$delete = $cronofy->deleteEvent($params);

Delete external events

To delete an external event from a user's calendar:, (*21)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'calendar_id' => 'CalendarID',
  'event_uid' => 'EventUID'
];

$delete = $cronofy->deleteExternalEvent($params);

Elevated permissions

To elevate a client's permissions for a user's calendar(s):, (*22)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'permissions' => [
    [
      'calendar_id' => 'CalendarID_1',
      'permission_level' => 'unrestricted'
    ],
    [
      'calendar_id' => 'CalendarID_2',
      'permission_level' => 'unrestricted'
    ]
  ],
  'redirect_uri' => 'http://yoursite.dev/elevate/callback'
];

$response = $cronofy->elevatedPermissions($params);

Authorize with a Service Account

To authorize a user's account using a service account:, (*23)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'email' => $email,
  'callback_url' => $callback_url,
  'scope' => ['read_account','list_calendars','read_events','create_event','delete_event']
];

$response = $cronofy->authorizeWithServiceAccount($params);

Note: You will need to use a Service Account access token to perform this action., (*24)

Create a Calendar

To create a calendar for a user's account profile:, (*25)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'profile_id' => $account_profile_id,
  'name' => $new_calendar_name
];

$response = $cronofy->createCalendar($params);

Using an Alternative Data Center

To use an alternative data center:, (*26)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken",
  "data_center" => "DataCenter"
]);

List Availability Rules

To retrieve all availability rules saved against an account:, (*27)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$response = $cronofy->listAvailabilityRules();

Read Availability Rule

To retrieve an availability rule:, (*28)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

// The String that uniquely identifies the availability rule.
$rule_id = "default";

$response = $cronofy->getAvailabilityRule($rule_id);

Delete Availability Rule

To delete an availability rule for the authenticated account:, (*29)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

// The String that uniquely identifies the availability rule.
$rule_id = "default";

$response = $cronofy->deleteAvailabilityRule($rule_id);

Create or Update Availability Rule

To create or update an availability rule for the authenticated account:, (*30)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

// The details of the event to create or update:
$params = [
    "availability_rule_id" => "default",
    "calendar_ids" => ["cal_123"],
    "tzid" => "America/Chicago",
    "weekly_periods" => [
        [
            "day" => "monday",
            "start_time" => "09:30",
            "end_time" => "12:30"
        ],
        [
            "day" => "wednesday",
            "start_time" => "09:30",
            "end_time" => "12:30"
        ]
    ]
];

$response = $cronofy->createAvailabilityRule($params);

Make a Batch request

Send multiple requests as a batch of operations via the [Batch][(https://docs.cronofy.com/developers/api/batch/) endpoint., (*31)

$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$eventData = [
  'calendar_id' => 'CalendarID',
  'event_id' => 'myapp-event-001',
  'summary' => 'Wyld Stallyns band practice',
  'start' => date("Y-m-d", strtotime('tomorrow')) . "T15:30:00Z",
  'end' => date("Y-m-d", strtotime('tomorrow')) . "T17:00:00Z",
];

$batch = Batch::create()
  ->upsertEvent($calendarId, $testEventData)
  ->deleteEvent($calendarId, $testEventId)

try {
  $result = $cronofy->executeBatch($batch);

  foreach ($result->responses() as $response) {
    // $response->status();
    // $response->headers();
    // $response->data();
    // $response->request();
  }
} catch (PartialBatchFailureException $exception) {
  $result = $exception->result();

  foreach ($result->errors() as $response) {
    // $response->status();
    // $response->headers();
    // $response->data();
    // $response->request();
  }
}

Running unit tests

make test

Migration guides

  • v0.X.X -> v1.0.0: version 1.0.0 adds namespacing and standardizes the names of public methods to camelCase (whereas previously some methods were named with camel_case). Where in v0.29.0 you would have written $cronofy = new Cronofy(); and $calendar = $cronofy->list_calendars();, for v1.0.0 you should write $cronofy = new Cronofy\Cronofy(); and $calendar = $cronofy->listCalendars();.

A feature I want is not in the SDK, how do I get it?

We add features to this SDK as they are requested, to focus on developing the Cronofy API., (*32)

If you're comfortable contributing support for an endpoint or attribute, then we love to receive pull requests! Please create a PR mentioning the feature/API endpoint you’ve added and we’ll review it as soon as we can., (*33)

If you would like to request a feature is added by our team then please let us know by getting in touch via support@cronofy.com., (*34)

The Versions

29/07 2018

dev-delete-external-events

dev-delete-external-events

  Sources   Download

29/07 2018

dev-join-scopes

dev-join-scopes

  Sources   Download

29/07 2018

dev-new-features

dev-new-features

  Sources   Download

23/05 2018

dev-master

9999999-dev

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

23/05 2018

v0.20.0

0.20.0.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

16/05 2018

dev-smart-invite-organizer

dev-smart-invite-organizer

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

11/04 2018

v0.19.0

0.19.0.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

09/04 2018

dev-private-events

dev-private-events

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

21/02 2018

v0.18.0

0.18.0.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

21/02 2018

dev-external-event-support

dev-external-event-support

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

02/02 2018

dev-get-events-iterator

dev-get-events-iterator

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

19/01 2018

v0.17.7

0.17.7.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

18/01 2018

v0.17.6

0.17.6.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

21/12 2017

v0.17.5

0.17.5.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

21/12 2017

dev-reminders-create-only

dev-reminders-create-only

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

05/12 2017

v0.17.4

0.17.4.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

05/12 2017

v0.17.3

0.17.3.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

30/11 2017

dev-send-gzip-accept-header

dev-send-gzip-accept-header

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

20/11 2017

v0.17.2

0.17.2.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

17/11 2017

dev-smart-invite-cancel

dev-smart-invite-cancel

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

01/11 2017

v0.17.1

0.17.1.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

25/10 2017

v0.17.0

0.17.0.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

authentication authorization oauth calendar client oauth2 cronofy

28/09 2017

v0.16.0

0.16.0.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

authentication authorization oauth calendar client oauth2 cronofy

30/08 2017

v0.15.0

0.15.0.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

authentication authorization oauth calendar client oauth2 cronofy

02/08 2017

v0.14.0

0.14.0.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

23/06 2017

v0.13.5

0.13.5.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

22/06 2017

dev-real-time-scheduling

dev-real-time-scheduling

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

21/06 2017

v0.13.4

0.13.4.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

21/06 2017

dev-add-expiry-to-token

dev-add-expiry-to-token

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

15/06 2017

v0.13.3

0.13.3.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

15/05 2017

v0.13.2

0.13.2.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

24/03 2017

v0.12.0

0.12.0.0

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

17/03 2017

dev-resources

dev-resources

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

17/03 2017

dev-attendees-support

dev-attendees-support

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

28/02 2017

dev-event-transparency

dev-event-transparency

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

19/01 2017

dev-availability-api

dev-availability-api

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

15/12 2016

dev-change-participation-status

dev-change-participation-status

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

14/12 2016

dev-update-with-alpha-feathres

dev-update-with-alpha-feathres

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

30/11 2016

dev-paged-iterator-error-handling

dev-paged-iterator-error-handling

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

25/11 2016

dev-include-status-codes-in-main-file

dev-include-status-codes-in-main-file

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

25/11 2016

dev-paged-result-iterators

dev-paged-result-iterators

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy

10/11 2016

dev-elevated-permissions

dev-elevated-permissions

PHP wrapper for Cronofy's unified calendar API

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

by Harry Boyes

authentication authorization oauth calendar client oauth2 cronofy