【问题标题】:php Google Calendar exclude read-only calendars from the listphp Google Calendar 从列表中排除只读日历
【发布时间】:2013-07-08 21:12:58
【问题描述】:

我正在显示一个日历列表,用户可以从中选择创建新活动。 我正在使用自己的帐户进行测试,其中一个日历是只读的,然后当我尝试在其中创建一个新事件时,逻辑上会返回一条错误消息,说明它是只读的。 如何从列表中排除只读日历?

function getGoogleCalendars()
{
    $html .= validateGoogleSession();
    if($html == "")
    {
        $client = getAuthSubHttpClient();
        $calendars = getCalendarList($client);

        if(!empty($calendars))
        {
            $html .= "<h1>Select Calendars</h1><br\>";
            $html .=  "<ul><br\>";
            foreach ($calendars as $calendar) 
            {
                //var_dump($calendar);
                $html .=  "<li>" . $calendar->title->text ." <input type='checkbox' name='gcalendar' value='".$calendar->content->src."' /></li><br\>";
            }
            $html .= "</ul><br\>";
            $html .= "<label>Alert: </label><input id='alert' type='checkbox' name='reminder[]' value='alert' />";
            $html .= "<label>E-mail: </label><input id='email' type='checkbox' name='reminder[]' value='email' />";
            $html .= "<label>Minutes before: </label><input id='minutes' type='input' name='minutes' value=15 />";
            $html .= "<button class='add-event'>Add Event</button>";
        }
    }
    return $html;
}

编辑

这是我遇到的错误:

致命错误:未捕获的异常 'Zend_Gdata_App_HttpException' 带有消息 'Expected response code 200, got 403 此提要是只读的'

这是日历提要:

https://www.google.com/calendar/feeds/%23contacts%40group.v.calendar.google.com/private/full

由于它已满且不是基本的,因此可以是或不是只读的:s

提前致谢!

【问题讨论】:

    标签: php zend-framework google-calendar-api icalendar


    【解决方案1】:

    在谷歌进行大量搜索后,我想我找到了解决方案,至少在我的示例中有效:

    if($calendar->accesslevel->value != "read" && $calendar->accesslevel->value != "freebusy" && $calendar->accesslevel->value != "none")
        $html .=  "<li>" . $calendar->title->text ." <input type='checkbox' name='gcalendar' value='".$calendar->content->src."' /></li><br\>";
    

    编辑

    经过更多搜索,我发现了几个可能有用的访问级别的含义:


    当前用户无权访问日历。
    阅读
    当前用户对日历具有​​只读访问权限。
    freebusy
    当前用户只能看到日历上的忙/闲信息,不能看到活动的详细信息。
    编辑器
    当前用户拥有日历的完全编辑权限,但不能更改日历的访问控制设置。
    所有者
    当前用户拥有日历的完全所有者访问权限。
    root
    仅在 Google Apps 域中可用。用户是域管理员,因此无论访问控制设置如何,都拥有对日历的完全所有者访问权限。

    我希望这对其他人有所帮助,因为找到答案并不容易。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多