4

我正在使用谷歌日历 API v3 来显示我的谷歌日历中的公共事件。

这是一段代码

require_once 'google-api-php-client-read-only/src/Google_Client.php';
require_once 'google-api-php-client-read-only/src/contrib/Google_CalendarService.php';
session_start();
$client = new Google_Client();
$client->setApplicationName("Calendar API Project");
$client->setDeveloperKey('xxxxxxxxxxxxxxx');
$service = new Google_CalendarService($client);
$events = $service->events->listEvents('u8v19163rlkb6qkhpj3e0ag2g0@group.calendar.google.com',array('maxResults'=>15));
$event = $service->events->get('u8v19163rlkb6qkhpj3e0ag2g0@group.calendar.google.com', $id);
$events = $events['items'];

foreach($events as $key=>$val){
    $events[] = $service->events->get('u8v19163rlkb6qkhpj3e0ag2g0@group.calendar.google.com', $val['id']);
}

问题是我正在获取与事件相关的所有信息,事件颜色除外。

请帮忙。

4

1 回答 1

1

有同样的问题,但通过将“更改事件”权限分配给与日历关联的客户端电子邮件地址,为我解决了这个问题。

https://github.com/google/google-api-php-client/issues/441

    ["items"]=>
array(1) {
  [0]=>
  array(16) {
    ["kind"]=>
    string(14) "calendar#event"
    ["etag"]=>
    string(18) ""2917142762918000""
    ["id"]=>
    string(26) "fmpd364h5pdu0u4oc66de8obao"
    ["status"]=>
    string(9) "confirmed"
    ["htmlLink"]=>
    string(116) "https://www.google.com/calendar/event?eid=Zm1wZDM2NGg1cGR1MHU0b2M2NmRlOG9iYW8gMWVxNW9zYXFsdGc4bThhcTE4YmpuampiYmtAZw"
    ["created"]=>
    string(24) "2016-03-21T14:04:24.000Z"
    ["updated"]=>
    string(24) "2016-03-21T14:43:01.459Z"
    ["summary"]=>
    string(4) "test"
    ["colorId"]=>
    string(2) "11"
于 2016-03-21T15:09:26.587 回答