【问题标题】:PHP Google Calendar get Event from specific calendarPHP Google Calendar 从特定日历获取事件
【发布时间】:2012-10-25 13:56:28
【问题描述】:

我在 Google 日历中有 2 个或更多日历。 我可以将事件添加到该特定日历,例如:

[...]
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Calendar($client);

//Set up  that loop again to find the new calendar:
$calFeed = $service->getCalendarListFeed();
foreach ($calFeed as $calendar) {
    if($calendar->title->text == "Calendar2")
         $appCalUrl = $calendar->content->src;
    }
}
[...]

try {

    $event           = $service->newEventEntry();
    $event->title    = $service->newTitle($title);

    $when            = $service->newWhen();
    $when->startTime = $start;
    $when->endTime   = $end;

    $event->when     = array($when);
    $newEvent        = $service->insertEvent($event, $appCalUrl);

    // fetch URI for edit, delete
    $uri = $newEvent->id->text;

} catch (Zend_Gdata_App_Exception $e) {
    echo "Error: " . $e->getResponse();
}

$uri 产生如下字符串: http://www.google.com/calendar/feeds/7b06drcai3lhc4lhhb0lgvv7sk%40group.calendar.google.com/private/full/ndp7g62tbbvknhi8bbhh9jfu9o

然后,使用:

try {

     $title = "test2";
     $event = $service->getCalendarEventEntry($uri);
     $event->title = $service->newTitle($title);
    } catch (Zend_Gdata_App_Exception $e) {
    die("Error: " . $e->getResponse());
} 

这总是会导致错误,例如:BAD / Invalid URI

我一直在搜索,在多个示例中都说 URI 格式应该是这样的:

getCalendarEventEntry('http://www.google.com/calendar/feeds/default/private/full/' . $id);

仅获取 ID 也不起作用。有什么想法吗?

【问题讨论】:

    标签: php google-calendar-api


    【解决方案1】:

    找到遮阳篷:

    字符串的格式为:

    http://www.google.com/calendar/feeds/$calendar_id%40group.calendar.google.com/private/full/$event_id
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-30
      • 2023-01-10
      • 1970-01-01
      • 2017-02-26
      • 2014-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多