【问题标题】:Changing color of a newly inserted Google Calender API event更改新插入的 Google Calendar API 事件的颜色
【发布时间】:2019-04-29 15:40:04
【问题描述】:

我正在尝试在我的 Google 日历中插入一个新活动。插入时,我想更改事件的颜色,因为它出现在 Google 日历上。 我到目前为止是这样的:

$event = new Google_Service_Calendar_Event(array(
   'start' => array(
        'dateTime' => '2018-09-14T00:00:00-07:00',
        'timeZone' => 'America/New_York'
    ),
   'end' => array(
        'dateTime' => '2018-09-21T23:59:59-07:00',
        'timeZone' => 'America/New_York'
    ),
   'backgroundColor' => "#C1292E"
));
    $parameter = array ('colorRgbFormat' => true);
    $calendarId = 'someemail@gmail.com';
    $event = $service->events->insert($calendarId, $event, $parameter);

如果您想设置颜色,文档中说将 colorRgbFormat 设置为 true:https://developers.google.com/calendar/v3/reference/calendarList/insert#examples

问题是,我设置它的方式是错误的。

如果我想更改插入事件的颜色,如何在 php 中将 colorRgbFormat 设置为参数?

【问题讨论】:

  • 这个链接可能对你有帮助link

标签: php google-calendar-api


【解决方案1】:

您可以使用以下方法更改事件的颜色:

$event = new Google_Service_Calendar_Event();
$event->setColorId(10);

有关详细信息,请参阅Google's API Docs
我还发现this question 信息量很大。

注意:这只会改变事件的图标颜色(见下面的截图)。
它不会更改事件的背景颜色。据我所知,没有办法改变事件的背景(即使在 Web UI 中也是不可能的)。

OP 在他们关于背景颜色的问题中所指的功能是指CalendarList#insert API 调用 - 这是当您想要将现有日历插入日历列表而不连接到编辑配置时事件。

希望这会有所帮助! :-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多