PHP API – Google Calendar – Updating Visibility

The Privacy / Visibility Part:

$event->visibility->value = "http://schemas.google.com/g/2005#event.private";

Here it is in context:

require_once 'Zend/Gdata/Extension/Visibility.php';
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
 
$user = [email protected]';
$pass = 'GOOGLEPASSWORD';
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar
$client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service);
 
function outputCalendarByURL($client,$url) 
{
  $retVal = false;
  $gdataCal = new Zend_Gdata_Calendar($client);
  $query = $gdataCal->newEventQuery();
  $query->setUser('default');
  $query->setVisibility('private');
  $query->setProjection('full');
  $query->setOrderby('starttime');
  $eventFeed = $gdataCal->getCalendarEventFeed($query);
  echo "<ul>\n";
  foreach ($eventFeed as $event) {
	if ($event->id->text == $url)
	{
		echo "\t<li>Title: " . $event->title->text .  "\n";
		//print_r($event);
		echo "\t\t<ul>\n";
		foreach ($event->when as $when) {
			//print_r($when);
		  echo "\t\t\t<li>Starts: " . $when->startTime . "</a></li>\n";
		  echo "\t\t\t<li>Ends: " . $when->endTime . "</a></li>\n";
		}
		echo "\t\t</ul>\n";
		echo "";
		echo "\t<li>Content: " . $event->content->text . "\n\t</li>\n";
		echo "\t<li>Link: " . $event->id->text . "\n\t</li>\n";
		echo "<input type=\"hidden\" value=\"" . $event->id->text . "\" name=\"eid\" />";
		$retVal = true;
	}
  }
  echo "</ul>\n";
  return $retVal;
}
 
 
function getEventByURL ($client, $EventURL) 
{
    $gdataCal = new Zend_Gdata_Calendar($client);
	$eventOld = $service->getCalendarEventEntry($EventURL);
	echo "Title: " . $eventOld->title->text . "<br />\n";
}
 
function updateEventsByURL($client, $newTitle, $EventURL) 
{
  $gdataCal = new Zend_Gdata_Calendar($client);
  $eventFeed = $gdataCal->getCalendarEventFeed();
  foreach ($eventFeed as $event) {
	if ($event->id->text == $EventURL)
	{
		$event->title = $gdataCal->newTitle($newTitle);
		$event->content = $gdataCal->newContent("Updated by: " . $_SERVER['REMOTE_ADDR'] . "");
		$event->visibility->value = "http://schemas.google.com/g/2005#event.private";
		$event->save();
	}
  }
}
function getEventByURL ($client, $EventURL) 
{
    $gdataCal = new Zend_Gdata_Calendar($client);
	$eventOld = $service->getCalendarEventEntry($EventURL);
	echo "Title: " . $eventOld->title->text . "<br />\n";
}
 
function updateEventsByURL($client, $newTitle, $EventURL) 
{
  $gdataCal = new Zend_Gdata_Calendar($client);
  $eventFeed = $gdataCal->getCalendarEventFeed();
  foreach ($eventFeed as $event) {
	if ($event->id->text == $EventURL)
	{
		$event->title = $gdataCal->newTitle($newTitle);
		$event->content = $gdataCal->newContent("Updated by: " . $_SERVER['REMOTE_ADDR'] . "");
		$event->visibility->value = "http://schemas.google.com/g/2005#event.private";
		$event->save();
	}
  }
}
 
updateEventsByURL($client, "Events New Title", "http://www.google.com/calendar/feeds/default/private/full/URLOFeventFROMevent_ID");
Facebooktwittergoogle_pluspinterest