1. Go to this page and download the library: Download timetree/timetree-sdk-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
timetree / timetree-sdk-php example snippets
use TimeTreeWebApi\OauthApp\OAuthAuthenticator;
$instance = new OAuthAuthenticator(
"<clientId>",
"<clientSecret>",
"<redirectUri>",
"<code>",
"<grantType>",
"<codeVerifier>",
);
$tokens = $instance->getToken();
// Please save this token
print_r($tokens);
use TimeTreeWebApi\OauthApp\OauthClient;
use TimeTreeWebApi\OauthApp\Parameter\GetCalendarsParams;
$instance = new OauthClient(
"<your-access-token>",
);
$calendars = $instance->getCalendars(new GetCalendarsParams());
print_r($calendars);
use TimeTreeWebApi\OauthApp\OauthClient;
use TimeTreeWebApi\OauthApp\Parameter\CreateEventParams;
use TimeTreeWebApi\OauthApp\Parameter\LabelsParams;
$instance = new OauthClient(
"<your-access-token>",
);
$event = $instance->createEvent(new CreateEventParams(
"ABCD", // CalendarID
"Event Title", // Event Title
"schedule", // "schedule" or "keep"
true, // Allday: true or false
new LabelsParams(1), // Label ID you want to set.
new DateTime("2021-01-01"), // Start time of the event you want to create.
null, // TimeZone of Start time
new DateTime("2021-01-01"), // End time of the event you want to create.
));
print_r($event);
use TimeTreeWebApi\CalendarApp\CalendarAppAuthenticator;
use TimeTreeWebApi\CalendarApp\CalendarAppClient;
$instance = new CalendarAppAuthenticator(
"<your-calendar-app-id>",
"-----BEGIN RSA PRIVATE KEY-----\n....-----END RSA PRIVATE KEY-----\n"
);
$token = $instance->getAccessToken("<installation-id>");
$client = new CalendarAppClient($token);
$calendar = $client->getCalendar();
print_r($calendar);
use TimeTreeWebApi\CalendarApp\CalendarAppAuthenticator;
use TimeTreeWebApi\CalendarApp\CalendarAppClient;
use TimeTreeWebApi\CalendarApp\Parameter\CreateEventParams;
$instance = new CalendarAppAuthenticator(
"<your-calendar-app-id>",
"-----BEGIN RSA PRIVATE KEY-----\n....-----END RSA PRIVATE KEY-----\n"
);
$token = $instance->getAccessToken("<installation-id>");
$client = new CalendarAppClient($token);
$params = new CreateEventParams(
"Event Title", // Event Title
"schedule", // "schedule" or "keep"
true, // Allday: true or false
new LabelsParams(1), // Label ID you want to set.
new DateTime("2021-01-01"), // Start time of the event you want to create.
null, // TimeZone of Start time
new DateTime("2021-01-01"), // End time of the event you want to create.
);
$response = $client->createEvent($params);
print_r($response);
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.