简体   繁体   中英

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

I am trying to use the Zend_Gdata_Calendar library to create a new event on the Google Calendar API and am struggling to work out how to set the visibility - has anyone any ideas how to actually do it?

The construct of my class has

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

Where the user_name and pass_word are the login details for an account which is able to write to the calendar. The following works

$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, and $content are text strings passed into the function)

However the visibility doesn't seam to get used.

I have tried the visibility shown above and also each of the following,

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

And while these all work (ie an event is created at the correct time) the private flag is never set!

Answering my own question you need to use a URI for it!

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM