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

时间:2010-02-03 13:49:42

标签: php api zend-framework gdata-api zend-gdata

嗨大家好我正在尝试从Google Calendar API中删除多个事件(从日期范围开始)。我正确地得到了饲料,这不是问题。问题是删除功能。我收到此错误:“错误:您必须指定要发布的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();

    } 

  }

1 个答案:

答案 0 :(得分:0)

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

修改:例如,以下是 ClientAuth 的使用方法:

$user = 'me@example.com';
$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.