gpt4 book ai didi

symfony - google calendar api 错误 400 - 资源 ID 值无效

转载 作者:行者123 更新时间:2023-12-05 01:44:38 25 4
gpt4 key购买 nike

我想使用 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);
}

最佳答案

您必须遵循此处定义的准则:https://developers.google.com/google-apps/calendar/v3/reference/events/insert

基本上,id 必须介于 5 到 1024 个字符之间,并且由以下字母表中的字符组成:0123456789abcdefghijklmnopqrstuv

关于symfony - google calendar api 错误 400 - 资源 ID 值无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45174205/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com