Do not use Zend, use the Google php client library. Below code is fully tested[https://github.com/google/google-api-php-client][1]
Go to the console and create a project
[ https://console.developers.google.com] [2]
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'google-api-php-client/autoload.php';
$client_id = "client_id";
$client_email = 'client_email';
$private_key = file_get_contents('Project-e7659df9db10.p12');
$scopes = array('https://www.googleapis.com/auth/calendar');
$credentials = new Google_Auth_AssertionCredentials(
$client_email,
$scopes,
$private_key
);
$client = new Google_Client();
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion();
}
$service = new Google_Service_Calendar($client);
$event = new Google_Service_Calendar_Event();
$event->setSummary('Interview');
$event->setLocation('Dell');
$event->sendNotifications=true;
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2015-02-14T10:00:00.000-07:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2015-02-14T11:00:00.000-07:00');
$event->setEnd($end);
$attendee1 = new Google_Service_Calendar_EventAttendee();
$attendee1->setEmail('some@someone.com');
$attendees = array($attendee1,
);
$event->attendees = $attendees;
$sendNotifications = array('sendNotifications' => true);
$createdEvent = $service->events->insert('primary', $event, $sendNotifications);
echo $createdEvent->getId();
[1]: https:
[2]: https:
source
share