am trying to sync. events from my website to google *calendar* after
user give me a permission to write on calendar .
Have you tried to read the reference?
Using quickAdd (which creates an event based on a simple string)
https://developers.google.com/google-apps/calendar/v3/reference/events/quickAdd
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_CalendarService.php';
$createdEvent = $service->events->quickAdd(
'primary',
'Appointment at Somewhere on June 3rd 10am-10:25am');
echo $createdEvent->getId();
Or using insert
https://developers.google.com/google-apps/calendar/v3/reference/events/insert
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_CalendarService.php';
$event = new Google_Event();
$event->setSummary('Appointment');
$event->setLocation('Somewhere');
$start = new EventDateTime();
$start->setDateTime('2011-06-03T10:00:00.000-07:00');
$event->setStart($start);
$end = new EventDateTime();
$end->setDateTime('2011-06-03T10:25:00.000-07:00');
$event->setEnd($end);
$attendee1 = new EventAttendee();
$attendee1->setEmail('attendeeEmail');
// ...
$attendees = array($attendee1,
// ...
);
$event->attendees = $attendees;
$createdEvent = $service->events->insert('primary', $event);
echo $createdEvent->getId();