没有从谷歌日历API v3获取谷歌日历事件的颜色ID

时间:2013-10-09 09:19:57

标签: php calendar google-calendar-api

我正在使用Google日历API v3来显示我的Google日历中的公共活动。

这是一段代码

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']);
}

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

请帮忙。

1 个答案:

答案 0 :(得分:0)

遇到同样的问题但是通过分配"对事件进行更改"与日历关联的客户端电子邮件地址的权限解决了我的问题。

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"