I am trying to integrate google calender APIv3 using php in my site.The idea is each user have a set of events as per his subscribed package on site on different dates.If the user select a new package later all events from previously subscribed package will overwrite with new one.
For me everything works fine except the following.
1)when a user reached gmail calender rendering page ,for the first time successfully created a calender (eg:My first work as name ) on left menu of My calender list and on that all events are inserted (for eg:events on march1,march5,march8 with different titles)
2)When the user click the link from site to render the same calender for the second time it will again created on left menu My calender list (eg:My first work and My first work two calenders with same name ).All events inserted on previous calender insertion will be there and the second time of insertion to same dates also will be there.(For eg: duplication of events on same dates march1,march5,march8 )
What i want is each time when a user click from site to render the calender page the calender should be created as a new one (this is working) and also the calender with same name on left menu "My calender list" should be deleted.So that there may not be duplicate data/event on same date.
any body please help me to find a solution?
following is my code snippet
$service = new Google_Service_Calendar($client);
$calendar = new Google_Service_Calendar_Calendar();
$calendar->setSummary('My first work');
$calendar->setTimeZone( 'Asia/Kolkata');
$createdCalendar = $service->calendars->insert($calendar);
$calendar = $service->calendars->get($createdCalendar->getId());
$calendarList = $service->calendarList->listCalendarList();
foreach($events_data_arr as $key=>$events_data_row)
{
$event = new Google_Service_Calendar_Event();
$event->setSummary($events_data_row['title']);
$event->setLocation('India');
$event->setDescription($events_data_row['description']);
$start = new Google_Service_Calendar_EventDateTime();
$start->setTimeZone('Asia/Kolkata');
$start->setDateTime($events_data_row['start_date'].'T10:00:00.000-07:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setTimeZone( 'Asia/Kolkata');
$end->setDateTime($events_data_row['end_date'].'T10:00:00.000-07:01');
$event->setEnd($end);
$createdEvent = $service->events->insert($createdCalendar->getId(), $event);
}