我正在尝试使用PHP中的Google Calendar API重新发生事件,并且它不会向我显示重复发生。
以下代码是我正在使用的代码:
$params = array(
'orderBy' => 'startTime',
'singleEvents' => true,
'timeMin' => date('c'),
);
$listarEventos = $service->events->listEvents($calendar_id, $params);
foreach ($listarEventos->getItems() as $i){
echo "<pre>";
echo $i->recurrence;
print_r($i);
echo "</pre>";
echo "<br>";
}
我正在获得这种类型的对象:
Google_Service_Calendar_Event Object
(
[collection_key:protected] => recurrence
[internal_gapi_mappings:protected] => Array
(
)
[anyoneCanAddSelf] =>
[attendeesType:protected] => Google_Service_Calendar_EventAttendee
[attendeesDataType:protected] => array
[attendeesOmitted] =>
[colorId] =>
[created] => 2015-06-01T07:34:46.000Z
[creatorType:protected] => Google_Service_Calendar_EventCreator
[creatorDataType:protected] =>
[description] =>
[endType:protected] => Google_Service_Calendar_EventDateTime
[endDataType:protected] =>
[endTimeUnspecified] =>
[etag] => "286628817348xxxx"
[extendedPropertiesType:protected] => Google_Service_Calendar_EventExtendedProperties
[extendedPropertiesDataType:protected] =>
[gadgetType:protected] => Google_Service_Calendar_EventGadget
[gadgetDataType:protected] =>
[guestsCanInviteOthers] =>
[guestsCanModify] =>
[guestsCanSeeOtherGuests] =>
[hangoutLink] =>
[htmlLink] => https://www.google.com/calendar/event?eid=czlqcW9uNmg1aGV0cTBwYXRrcnIxc2dqc3MgcHJ1ZWJhY2FsZW5kYXJpbxxxxxt
[iCalUID] => s9jqon6h5hetq0patkrr1sgjss@google.com
[id] => s9jqon6h5hetq0patkrr1sxxxxx
[kind] => calendar#event
[location] => Gra
[locked] =>
[organizerType:protected] => Google_Service_Calendar_EventOrganizer
[organizerDataType:protected] =>
[originalStartTimeType:protected] => Google_Service_Calendar_EventDateTime
[originalStartTimeDataType:protected] =>
[privateCopy] =>
[recurrence] =>
[recurringEventId] =>
[remindersType:protected] => Google_Service_Calendar_EventReminders
[remindersDataType:protected] =>
[sequence] => 0
[sourceType:protected] => Google_Service_Calendar_EventSource
[sourceDataType:protected] =>
[startType:protected] => Google_Service_Calendar_EventDateTime
[startDataType:protected] =>
[status] => confirmed
[summary] => Prueba recurrencia
[transparency] =>
[updated] => 2015-06-01T07:34:46.742Z
[visibility] =>
[modelData:protected] => Array
(
[creator] => Array
(
[email] => xxxx@gmail.com
[displayName] => Prueba Calendario
[self] => 1
)
[organizer] => Array
(
[email] => xxxxx@gmail.com
[displayName] => Prueba Calendario
[self] => 1
)
[start] => Array
(
[dateTime] => 2015-06-19T03:01:00+02:00
[timeZone] => Europe/Madrid
)
[end] => Array
(
[dateTime] => 2015-06-19T09:03:00+02:00
[timeZone] => Europe/Madrid
)
[reminders] => Array
(
[useDefault] => 1
)
)
[processed:protected] => Array
(
)
)
我必须说我使用以下代码存储重复:
$event->setRecurrence(array('RRULE:FREQ='.$FREQ.';INTERVAL='.$INTERVAL));
我已经证明事件是经常发生的,所以我不知道为什么我不能再复发。
非常感谢!
答案 0 :(得分:0)
如果您使用'singleEvents' => true
,则不会再次发生。
文档(https://developers.google.com/google-apps/calendar/v3/reference/events/list)说:
singleEvents boolean 是否将重复事件扩展到实例中,并且仅返回单个一次性事件和重复事件的实例,而不返回基础的周期性事件本身。可选的。默认值为False。
答案 1 :(得分:0)
我已经解决了这个问题。如果你没有得到这样的事件,你将不会再次发生:
$event = $service->events->get('primary', "recurringEventId");
获得$ event后,您可以使用:
$preevent->recurrence[0]
感谢Xeron的回答。