开发者

Preventing individually deleted recurring Google Calendar entries from appearing via Zend?

开发者 https://www.devze.com 2023-04-13 04:40 出处:网络
I\'m creating a website with a planner and want to synchronize it with a Google Calendar. So far it works pretty well using the GData Class of the Zend framework. I\'m running into a problemwhere recu

I'm creating a website with a planner and want to synchronize it with a Google Calendar. So far it works pretty well using the GData Class of the Zend framework. I'm running into a problem where recurring events appear every week, even if they are individually deleted. I have tried:

$query->setParam('singleevents','true');

But now a lot of events don't show up at the first weeks of my planner and at some weeks I simply miss a few events. This is the basic structure of my script:

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_HttpClient');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
$service = new Zend_Gdata_Calendar();
$query = $service->newEventQuery();    
$query->setUser('mypubliccalendar@gmail.com');    
$query->setVisibility('public');
$query->setProjection('full');
$query->setStartMin(date('Y-m-d', strtotime(week_start_date("Y-m-d H:i:s"))));
$query->setStartMax(date('Y-m-d', strtotime(week_start_date("Y-m-d H:i:s")) +
    (60*60*24*7*10)));
$query-&开发者_StackOverflow中文版gt;setOrderby('starttime');
$query->setParam('singleevents','true');

try { 
    $eventFeed = $service->getCalendarEventFeed($query); 
}

catch (Zend_Gdata_App_Exception $e) { 
    return; 
}

foreach ($eventFeed as $event) {        
    foreach ($event->when as $when) {
         // transform data
    }
}

What can I do to make my planner get the exact same data as my Google Calendar?


I found the solution. I guess the zend framework uses the resultsPerPage value in the XML feed. Since events are retrieved in reversed chronological order, and there where 55 entry's in my date range of 10 weeks, the first weeks stayed empty. I decided to go for the easy solution and reduced my date range to 5 weeks. Now it works perfectly!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号