8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
18 * @subpackage Calendar
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
27 require_once 'Zend/Gdata.php';
30 * @see Zend_Gdata_Calendar_EventFeed
32 require_once 'Zend/Gdata/Calendar/EventFeed.php';
35 * @see Zend_Gdata_Calendar_EventEntry
37 require_once 'Zend/Gdata/Calendar/EventEntry.php';
40 * @see Zend_Gdata_Calendar_ListFeed
42 require_once 'Zend/Gdata/Calendar/ListFeed.php';
45 * @see Zend_Gdata_Calendar_ListEntry
47 require_once 'Zend/Gdata/Calendar/ListEntry.php';
50 * Service class for interacting with the Google Calendar data API
51 * @link http://code.google.com/apis/gdata/calendar.html
55 * @subpackage Calendar
56 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
57 * @license http://framework.zend.com/license/new-bsd New BSD License
59 class Zend_Gdata_Calendar extends Zend_Gdata
62 const CALENDAR_FEED_URI = 'http://www.google.com/calendar/feeds';
63 const CALENDAR_EVENT_FEED_URI = 'http://www.google.com/calendar/feeds/default/private/full';
64 const AUTH_SERVICE_NAME = 'cl';
66 protected $_defaultPostUri = self::CALENDAR_EVENT_FEED_URI;
69 * Namespaces used for Zend_Gdata_Calendar
73 public static $namespaces = array(
74 array('gCal', 'http://schemas.google.com/gCal/2005', 1, 0)
78 * Create Gdata_Calendar object
80 * @param Zend_Http_Client $client (optional) The HTTP client to use when
81 * when communicating with the Google servers.
82 * @param string $applicationId The identity of the app in the form of Company-AppName-Version
84 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
86 $this->registerPackage('Zend_Gdata_Calendar');
87 $this->registerPackage('Zend_Gdata_Calendar_Extension');
88 parent::__construct($client, $applicationId);
89 $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
93 * Retreive feed object
95 * @param mixed $location The location for the feed, as a URL or Query
96 * @return Zend_Gdata_Calendar_EventFeed
98 public function getCalendarEventFeed($location = null)
100 if ($location == null) {
101 $uri = self::CALENDAR_EVENT_FEED_URI;
102 } else if ($location instanceof Zend_Gdata_Query) {
103 $uri = $location->getQueryUrl();
107 return parent::getFeed($uri, 'Zend_Gdata_Calendar_EventFeed');
111 * Retreive entry object
113 * @return Zend_Gdata_Calendar_EventEntry
115 public function getCalendarEventEntry($location = null)
117 if ($location == null) {
118 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
119 throw new Zend_Gdata_App_InvalidArgumentException(
120 'Location must not be null');
121 } else if ($location instanceof Zend_Gdata_Query) {
122 $uri = $location->getQueryUrl();
126 return parent::getEntry($uri, 'Zend_Gdata_Calendar_EventEntry');
131 * Retrieve feed object
133 * @return Zend_Gdata_Calendar_ListFeed
135 public function getCalendarListFeed()
137 $uri = self::CALENDAR_FEED_URI . '/default';
138 return parent::getFeed($uri,'Zend_Gdata_Calendar_ListFeed');
142 * Retreive entryobject
144 * @return Zend_Gdata_Calendar_ListEntry
146 public function getCalendarListEntry($location = null)
148 if ($location == null) {
149 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
150 throw new Zend_Gdata_App_InvalidArgumentException(
151 'Location must not be null');
152 } else if ($location instanceof Zend_Gdata_Query) {
153 $uri = $location->getQueryUrl();
157 return parent::getEntry($uri,'Zend_Gdata_Calendar_ListEntry');
160 public function insertEvent($event, $uri=null)
163 $uri = $this->_defaultPostUri;
165 $newEvent = $this->insertEntry($event, $uri, 'Zend_Gdata_Calendar_EventEntry');