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.
19 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 * @version $Id: Gbase.php 16971 2009-07-22 18:05:45Z mikaelkael $
27 require_once 'Zend/Gdata.php';
30 * @see Zend_Gdata_Gbase_ItemFeed
32 require_once 'Zend/Gdata/Gbase/ItemFeed.php';
35 * @see Zend_Gdata_Gbase_ItemEntry
37 require_once 'Zend/Gdata/Gbase/ItemEntry.php';
40 * @see Zend_Gdata_Gbase_SnippetEntry
42 require_once 'Zend/Gdata/Gbase/SnippetEntry.php';
45 * @see Zend_Gdata_Gbase_SnippetFeed
47 require_once 'Zend/Gdata/Gbase/SnippetFeed.php';
50 * Service class for interacting with the Google Base data API
52 * @link http://code.google.com/apis/base
57 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
58 * @license http://framework.zend.com/license/new-bsd New BSD License
60 class Zend_Gdata_Gbase
extends Zend_Gdata
64 * Path to the customer items feeds on the Google Base server.
66 const GBASE_ITEM_FEED_URI
= 'http://www.google.com/base/feeds/items';
69 * Path to the snippets feeds on the Google Base server.
71 const GBASE_SNIPPET_FEED_URI
= 'http://www.google.com/base/feeds/snippets';
74 * Authentication service name for Google Base
76 const AUTH_SERVICE_NAME
= 'gbase';
79 * The default URI for POST methods
83 protected $_defaultPostUri = self
::GBASE_ITEM_FEED_URI
;
86 * Namespaces used for Zend_Gdata_Gbase
90 public static $namespaces = array(
91 array('g', 'http://base.google.com/ns/1.0', 1, 0),
92 array('batch', 'http://schemas.google.com/gdata/batch', 1, 0)
96 * Create Zend_Gdata_Gbase object
98 * @param Zend_Http_Client $client (optional) The HTTP client to use when
99 * when communicating with the Google Apps servers.
100 * @param string $applicationId The identity of the app in the form of Company-AppName-Version
102 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
104 $this->registerPackage('Zend_Gdata_Gbase');
105 $this->registerPackage('Zend_Gdata_Gbase_Extension');
106 parent
::__construct($client, $applicationId);
107 $this->_httpClient
->setParameterPost('service', self
::AUTH_SERVICE_NAME
);
111 * Retreive feed object
113 * @param mixed $location The location for the feed, as a URL or Query
114 * @return Zend_Gdata_Gbase_ItemFeed
116 public function getGbaseItemFeed($location = null)
118 if ($location === null) {
119 $uri = self
::GBASE_ITEM_FEED_URI
;
120 } else if ($location instanceof Zend_Gdata_Query
) {
121 $uri = $location->getQueryUrl();
125 return parent
::getFeed($uri, 'Zend_Gdata_Gbase_ItemFeed');
129 * Retreive entry object
131 * @param mixed $location The location for the feed, as a URL or Query
132 * @return Zend_Gdata_Gbase_ItemEntry
134 public function getGbaseItemEntry($location = null)
136 if ($location === null) {
137 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
138 throw new Zend_Gdata_App_InvalidArgumentException(
139 'Location must not be null');
140 } else if ($location instanceof Zend_Gdata_Query
) {
141 $uri = $location->getQueryUrl();
145 return parent
::getEntry($uri, 'Zend_Gdata_Gbase_ItemEntry');
151 * @param Zend_Gdata_Gbase_ItemEntry $entry The Base entry to upload
152 * @param boolean $dryRun Flag for the 'dry-run' parameter
153 * @return Zend_Gdata_Gbase_ItemFeed
155 public function insertGbaseItem($entry, $dryRun = false)
157 if ($dryRun == false) {
158 $uri = $this->_defaultPostUri
;
160 $uri = $this->_defaultPostUri
. '?dry-run=true';
162 $newitem = $this->insertEntry($entry, $uri, 'Zend_Gdata_Gbase_ItemEntry');
169 * @param Zend_Gdata_Gbase_ItemEntry $entry The Base entry to be updated
170 * @param boolean $dryRun Flag for the 'dry-run' parameter
171 * @return Zend_Gdata_Gbase_ItemEntry
173 public function updateGbaseItem($entry, $dryRun = false)
175 $returnedEntry = $entry->save($dryRun);
176 return $returnedEntry;
182 * @param Zend_Gdata_Gbase_ItemEntry $entry The Base entry to remove
183 * @param boolean $dryRun Flag for the 'dry-run' parameter
184 * @return Zend_Gdata_Gbase_ItemFeed
186 public function deleteGbaseItem($entry, $dryRun = false)
188 $entry->delete($dryRun);
193 * Retrieve feed object
195 * @param mixed $location The location for the feed, as a URL or Query
196 * @return Zend_Gdata_Gbase_SnippetFeed
198 public function getGbaseSnippetFeed($location = null)
200 if ($location === null) {
201 $uri = self
::GBASE_SNIPPET_FEED_URI
;
202 } else if ($location instanceof Zend_Gdata_Query
) {
203 $uri = $location->getQueryUrl();
207 return parent
::getFeed($uri, 'Zend_Gdata_Gbase_SnippetFeed');