从 google 日历中删除的事件仍然出现在 listEvents 中
events removed from google calendar still appears on listEvents
我在从我的应用程序中删除事件时遇到问题(甚至从 google 日历中删除)。我有我所有活动的日历,我第一次尝试删除一个活动,它 "works":我更改浏览器的选项卡,看到 Google 日历面板,活动已成功已删除,太棒了!!但是,如果我重新加载我的应用程序的选项卡...我仍然会看到该事件!!!
此外,如果我从 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();
}
}
新编辑
还有一件事......当我第一次删除一个事件时没有问题(并且该事件在 google 日历上被删除),当我刷新我的应用程序页面时该事件仍然存在,当我再次尝试删除它时,出现此错误:
<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>";
您的应用不应显示状态为已取消的事件。
我在从我的应用程序中删除事件时遇到问题(甚至从 google 日历中删除)。我有我所有活动的日历,我第一次尝试删除一个活动,它 "works":我更改浏览器的选项卡,看到 Google 日历面板,活动已成功已删除,太棒了!!但是,如果我重新加载我的应用程序的选项卡...我仍然会看到该事件!!!
此外,如果我从 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();
}
}
新编辑
还有一件事......当我第一次删除一个事件时没有问题(并且该事件在 google 日历上被删除),当我刷新我的应用程序页面时该事件仍然存在,当我再次尝试删除它时,出现此错误:
<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>";
您的应用不应显示状态为已取消的事件。