我正在尝试使用 Google_CalendarService 检索所有事件。到目前为止,我正在使用重复事件检索所有内容,但是有些事件没有出现。
示例:我在 22-okt、23-okt 和 24-okt 有活动。它们都是正常事件,但我得到的唯一事件是 22 和 23。24 没有出现,但它确实存在于我的日历中!
[更新] 发现另一个问题!每次我通过我的应用程序编辑现有事件时,该事件都会消失,但确实存在于日历中!
这是我获取数据的代码:
API 设置:
function calSettings(){
$client = new Google_Client();
$cal = new Google_CalendarService($client);
$client->setAccessType('offline');
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
$sessionToken = json_decode($_SESSION['token']);
$this->Cookie->write('token', $sessionToken->refresh_token, false, '1 month');
}
$cookie = $this->Cookie->read('token');
if(!empty($cookie)){
$client->refreshToken($this->Cookie->read('token'));
}
$serviceArr = array('client' => $client, 'service' => $cal);
return $serviceArr;
}
获取事件:
public function initCalendar($ownerCalendarId = null, $eventID = null){
$serviceArr = $this->calSettings();
$client = $serviceArr['client'];
$cal = $serviceArr['service'];
$wandaCalendarId = 'gmail@gmail.com';
if ($client->getAccessToken()) {
/************* Code entry *************/
if($eventID != null){
$events = $cal->events->get($ownerCalendarId, $eventID);
}else{
$ownerEvents = $cal->events->listEvents($ownerCalendarId);
if($ownerCalendarId != $wandaCalendarId){
$wandaEvents = $cal->events->listEvents($wandaCalendarId);
$events = array('owner' => $ownerEvents, 'wanda' => $wandaEvents);
}else{
$events = array('owner' => $ownerEvents, 'wanda' => '');
}
}
return $events;
}else{
/************* Not connected to google calendar code *************/
$authUrl = $client->createAuthUrl();
$returnArr = array('status' => 'false', 'message' => "<a class='login' href='$authUrl'>Connect Me!</a>");
return $returnArr;
}
}
所以有了这段代码,我得到了大部分事件,为什么其他事件没有出现?以前有人遇到过这个问题吗?