【发布时间】:2016-05-09 12:23:11
【问题描述】:
当我从我的应用程序中删除一个事件(甚至从谷歌日历中)时,我遇到了一个问题。我有我所有活动的日历,我第一次尝试删除一个活动,它“有效”:我更改了浏览器的标签,看到 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();
}
}
新编辑
还有一件事...当我第一次删除事件时没有问题(并且该事件在谷歌日历上已删除),当我刷新我的应用页面时,事件仍然存在,当我尝试再次删除它我得到这个错误:
<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
资源已被删除...是的!!!我知道!!!为什么还存在??????
【问题讨论】:
-
请交叉检查您的活动 ID 和日历 ID 是否正确...
-
嗨@Vipin。是的...我查看了日历 ID,它与我的谷歌日历 ID 匹配,关于事件 ID,我如何在谷歌日历面板上查看 ID??
-
$events = $service->events->listEvents($calendarListEntry->id); var_dump($事件);试试这个,你会得到事件 id 然后在 code$result = $service->events->delete('calendar_id', 'event_id'); 下运行回声“
=========================
”; var_dump($result);回声“
=========================
”; -
请告诉我
标签: php google-calendar-api google-api-php-client