使用Zend Google Calendar API PHP框架创建一个私有事件


Create a private event using the Zend Google Calendar API PHP framework

我试图使用Zend_Gdata_Calendar库在Google日历API上创建一个新事件,我正在努力找出如何设置可见性-有人有任何想法如何实际做到这一点吗?

我的类的构造有

$this->calendar_client = Zend_Gdata_ClientLogin::getHttpClient($this->user_name, $this->password, Zend_Gdata_Calendar::AUTH_SERVICE_NAME);

user_name和pass_word是能够写入日历的帐户的登录详细信息。以下作品

$gdataCal = new Zend_Gdata_Calendar($this->calendar_client);
$newEvent = $gdataCal->newEventEntry();
$newEvent->title = $gdataCal->newTitle($title);
$newEvent->where = array($gdataCal->newWhere($where));
$newEvent->content = $gdataCal->newContent($content);
$newEvent->visibility = 'private';
$when = $gdataCal->newWhen();
 $when->startTime   = $start_time;
 $when->endTime     = $end_time;
$newEvent->when = array($when);
$createdEvent = $gdataCal->insertEvent($newEvent,"https://www.google.com/calendar/feeds/{$email}/private/full");

($title, $where和$content是传递给函数的文本字符串)

然而,可见性并没有被使用。

我尝试了上面显示的可见性,也尝试了下面的每个,

$newEvent->setVisibility($gdataCal->newVisibility('private'));
$newEvent->setVisibility($gdataCal->newVisibility(true));
$newEvent->setVisibility($gdataCal->newVisibility(false));

当这些都工作时(即在正确的时间创建事件),私有标志永远不会设置!

回答我自己的问题,您需要为它使用一个URI !

$newEvent->visibility   = $gdataCal->newVisibility("http://schemas.google.com/g/2005#event.public");
$newEvent->visibility   = $gdataCal->newVisibility("http://schemas.google.com/g/2005#event.private");