当我从应用程序(甚至从谷歌日历)中删除事件时,我遇到了一个问题。我有我的日历和我所有的事件,我第一次尝试删除一个事件,它"有效":我更改浏览器的选项卡,看到谷歌日历面板,事件已经成功删除,太棒了!!但是,如果我重新加载应用程序的选项卡。。。我仍然看到活动
此外,如果我从Google日历面板中删除数据,应用程序仍然会在API调用上恢复此事件:
$service->events->listEvents($calendar,$eventsParam);
$service是Google_service_Calendar对象。
谢谢。
编辑
这是我删除事件的方式:
public function removedate()
{
$service = getService();
$service->events->delete($this->input->post("calendar"), getEventId($service));
}
我正在使用codeigniter,我正在使用一个自己制作的助手来完成最习惯的功能,在这两个功能之间:
function getService($file=false)
{
$ci =& get_instance();
if($file)
$file = CREDENTIALS_PATH.$file;
else
$file = CREDENTIALS_PATH.$ci->session->userdata("identity").".json";
$ci->g_client->setAccessToken(file_get_contents($file));
return new Google_Service_Calendar($ci->g_client);
}
function getEventId($service)
{
$ci =& get_instance();
$id = $ci->input->post("id");
$dni = $id;
if(!is_numeric($id))
$id = $ci->general_model->getData("users","phone", array("dni"=>$id), true)->phone;
$min = false;
$max = false;
if($ci->input->post("min"))
$min = date("c", strtotime ( '-2 hour' , strtotime ( (new DateTime(explode("GMT", $ci->input->post("min"))[0]))->format("c"))));
if($ci->input->post("max"))
$max = (new DateTime(explode("GMT", $ci->input->post("max"))[0]))->format("c");
$events = getDates($service, $ci->input->post("calendar"), $min, $max);
foreach ($events->getItems() as $event)
{
if($id==$event->getSummary() || $dni==$event->getSummary())
return $event->getId();
}
}
新版
还有一件事。。。当我第一次删除一个事件时没有问题(该事件在谷歌日历上被删除),当我刷新应用程序页面时,该事件仍然存在,当我再次尝试删除它时,我会收到以下错误:
<br />
<b>Fatal error</b>: Uncaught exception 'Google_Service_Exception' with message 'Error calling DELETE
https://www.googleapis.com/calendar/v3/calendars/cnhkehagcve7rm8s1g88hauer8%40group.calendar.google.com/events/97smpf2320s3lmg8nnnpb9dndc: (410)
Resource has been deleted' in
/var/www/html/prototipo/application/third_party/vendor/google/apiclient/src/Google/Http/REST.php:110
资源已被删除。。。对我知道!!!为什么它仍然存在??????
您的应用程序不应显示状态为已取消的事件。
获取所有事件
$events = $service->events->listEvents('<calendar_id>');
要从日历中删除任何事件
$result = $service->events->delete('<calendar_id>', '<event_id>');
echo "<br>========================<br>";
var_dump($result);
echo "<br>========================<br>";