获取Google日历事件颜色(通过PHP)

时间:2015-01-05 14:30:47

标签: php api google-api google-calendar-api google-api-php-client

我正在尝试从Google日历中获取事件的颜色。标题,desc和日期已经有效。但我不明白它的颜色。

我使用Sarah Bailey的守则。

$newmonth = $eventdate->format("M");
     $newday = $eventdate->format("j");
     $newtime = $eventdate->format("H:i");
     $description = $event->description;

    ?>

<div class="entry">
    <div class="color" style="background-color: #_HERE COLOR OF EVENT_;">
        ---
    </div>

你能帮助我从事件中获取ColorId吗?

祝你好运!

1 个答案:

答案 0 :(得分:0)

你试过colors get吗?

$colors = $service->colors->get();

// Print available calendarListEntry colors.
foreach ($colors->getCalendar() as $key => $color) {
  print "colorId : {$key}\n";
  print "  Background: {$color->getBackground()}\n";
  print "  Foreground: {$color->getForeground()}\n";
}
// Print available event colors.
foreach ($colors->getEvent() as $key => $color) {
  print "colorId : {$key}\n";
  print "  Background: {$color->getBackground()}\n";
  print "  Foreground: {$color->getForeground()}\n";
}