我无法使用 Google 数据 API 删除事件源

发布于 2024-08-20 06:40:44 字数 939 浏览 5 评论 0原文

大家好,我正在尝试从 Google Calendar API(从某个日期范围)删除多个事件。我正确地获取了 feed,这不是问题。问题是删除功能。我收到此错误:“错误:您必须指定要发布到的 URI。”

有人可以帮我吗!

谢谢

  $service = new Zend_Gdata_Calendar($client);

  $query = $service->newEventQuery();

  $query->setUser('XXXXX');
  $query->setVisibility('private-XXXX');
  $query->setProjection('full');
  $query->setOrderby('starttime');
  $query->setStartMin('2010-01-20');
  $query->setStartMax('2010-01-28');
  // Retrieve the event list from the calendar server

  try {

      $eventFeed = $service->getCalendarEventFeed($query);

  } catch (Zend_Gdata_App_Exception $e) {

      echo "Error: " . $e->getMessage();

  }



  // Iterate through the list of events, deleting them //

  foreach ($eventFeed as $event) {

    try{
    $event->delete();
    }
    catch (Zend_Gdata_App_Exception $e) {

        echo "Error: " . $e->getMessage();

    } 

  }

Hi Guys I'm trying to delete multiple events from the Google Calendar API (From a date range). I get the feed correctly, this is not the problem. The probleme is the delete function. I get this error : "Error: You must specify an URI to which to post."

Can somebody please help me!

Thank You

  $service = new Zend_Gdata_Calendar($client);

  $query = $service->newEventQuery();

  $query->setUser('XXXXX');
  $query->setVisibility('private-XXXX');
  $query->setProjection('full');
  $query->setOrderby('starttime');
  $query->setStartMin('2010-01-20');
  $query->setStartMax('2010-01-28');
  // Retrieve the event list from the calendar server

  try {

      $eventFeed = $service->getCalendarEventFeed($query);

  } catch (Zend_Gdata_App_Exception $e) {

      echo "Error: " . $e->getMessage();

  }



  // Iterate through the list of events, deleting them //

  foreach ($eventFeed as $event) {

    try{
    $event->delete();
    }
    catch (Zend_Gdata_App_Exception $e) {

        echo "Error: " . $e->getMessage();

    } 

  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁许谁一生繁华 2024-08-27 06:40:44

您似乎正在使用MagicCookie身份验证,这将为您提供只读访问权限。要获得读/写访问权限,您需要使用 ClientAuthAuthSub 身份验证。

编辑:例如,以下是如何使用ClientAuth

$user = '[email protected]';
$pass = 'password';

$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$client  = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Calendar($client);

$query = $service->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
// Rest of your code.

It looks like you're using MagicCookie authentication, which will give you read-only access. To get read/write access you will need to use ClientAuth or AuthSub authentication.

Edit: For example, here's how to use ClientAuth:

$user = '[email protected]';
$pass = 'password';

$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$client  = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Calendar($client);

$query = $service->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
// Rest of your code.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文