timetree/timetree-sdk-php
is simple HTTP client for requesting to TimeTree's Web API.
timetree-sdk-php
uses a modified version of Semantic Versioning for all changes.
You can install timetree-sdk-php via composer or download this code.
composer require timetree/timetree-sdk-php
Please see here for OauthApp. docs
<?php
use TimeTreeWebApi\OauthApp\OAuthAuthenticator;
$instance = new OAuthAuthenticator(
"<clientId>",
"<clientSecret>",
"<redirectUri>",
"<code>",
"<grantType>",
"<codeVerifier>",
);
$tokens = $instance->getToken();
// Please save this token
print_r($tokens);
<?php
use TimeTreeWebApi\OauthApp\OauthClient;
use TimeTreeWebApi\OauthApp\Parameter\GetCalendarsParams;
$instance = new OauthClient(
"<your-access-token>",
);
$calendars = $instance->getCalendars(new GetCalendarsParams());
print_r($calendars);
<?php
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);
Please see here for CalendarApp. docs
<?php
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);
<?php
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);
timetree-sdk-php
depends on guzzle. So Exceptions also throw guzzle's as it is.
Read License for more licensing information.