根据文档(参考日历和颜色),可以通过属性“backgroundColor”、“foregroundColor”和/或“colorId”检索日历颜色。
在我原来的 Google 日历中,我有一个名为“cacao”的日历,当我检查页面时,该日历的颜色为rgb(121, 85, 72) / #795548。但是,当我通过 API 检索该议程的颜色时(直接从 Calendar 对象中获取 backgroundColor 值或通过在 Colors 对象中查找 colorId,它们都匹配),返回的颜色为 rgb( 202, 189, 191) / #cabdbf。我尝试的每种预设颜色都会发生这种不匹配。当我在 Google 日历中选择自定义颜色时,该自定义值会通过 API 正确传递。
如何通过 Google Calendar API 获取预设日历颜色的正确颜色值?
编辑 - 在下面添加了代码片段
扩展类客户端:
function getCalendars()
{
$service = new Google_Service_Calendar($this);
$calendarList = $service->calendarList->listCalendarList();
while (true) {
foreach ($calendarList->getItems() as $calendarListEntry) {
$calendars[] = $calendarListEntry;
}
$pageToken = $calendarList->getNextPageToken();
if ($pageToken) …Run Code Online (Sandbox Code Playgroud)