小编Rom*_*ill的帖子

谷歌日历 API 错误 400 - 资源 ID 值无效

我想使用 Symfony 命令(批量)通过 API 在 Google 日历中插入事件。

当我插入 ID 类似于“event01487”的事件时,它会抛出以下错误:“code”:400,“message”:“无效的资源 id 值。”

这个 id 是唯一的,因为没有插入任何事件 - 它甚至没有插入一次。该 ID 似乎符合 Google 要求...

你知道我为什么得到这个吗?

foreach($bookingsToSync as $booking){
     $event = new Google_Service_Calendar_Event();
     $event->setId($booking['id']);
     $event->setSummary($booking['title']);
     $event->setDescription($booking['description']);

     $start = new \Google_Service_Calendar_EventDateTime();
     $start->setDateTime($booking['startDate']->format(DateTime::ATOM));
     $event->setStart($start);
     $end = new \Google_Service_Calendar_EventDateTime();
     $end->setDateTime($booking['endDate']->format(DateTime::ATOM));
     $event->setEnd($end);

     $output->writeln($event->getId());

     $service->events->insert($calendarId, $event);
}
Run Code Online (Sandbox Code Playgroud)

google-calendar-api google-api symfony

3
推荐指数
1
解决办法
5715
查看次数

标签 统计

google-api ×1

google-calendar-api ×1

symfony ×1