14 * to license@zend.com so we can send you a copy immediately. |
14 * to license@zend.com so we can send you a copy immediately. |
15 * |
15 * |
16 * @category Zend |
16 * @category Zend |
17 * @package Zend_Gdata |
17 * @package Zend_Gdata |
18 * @subpackage Gbase |
18 * @subpackage Gbase |
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
21 * @version $Id: Gbase.php 20096 2010-01-06 02:05:09Z bkarwin $ |
21 * @version $Id: Gbase.php 24777 2012-05-08 18:50:23Z adamlundrigan $ |
22 */ |
22 */ |
|
23 |
|
24 /** |
|
25 * @see Zend_Exception |
|
26 */ |
|
27 require_once 'Zend/Exception.php'; |
23 |
28 |
24 /** |
29 /** |
25 * @see Zend_Gdata |
30 * @see Zend_Gdata |
26 */ |
31 */ |
27 require_once 'Zend/Gdata.php'; |
32 require_once 'Zend/Gdata.php'; |
28 |
|
29 /** |
|
30 * @see Zend_Gdata_Gbase_ItemFeed |
|
31 */ |
|
32 require_once 'Zend/Gdata/Gbase/ItemFeed.php'; |
|
33 |
|
34 /** |
|
35 * @see Zend_Gdata_Gbase_ItemEntry |
|
36 */ |
|
37 require_once 'Zend/Gdata/Gbase/ItemEntry.php'; |
|
38 |
|
39 /** |
|
40 * @see Zend_Gdata_Gbase_SnippetEntry |
|
41 */ |
|
42 require_once 'Zend/Gdata/Gbase/SnippetEntry.php'; |
|
43 |
|
44 /** |
|
45 * @see Zend_Gdata_Gbase_SnippetFeed |
|
46 */ |
|
47 require_once 'Zend/Gdata/Gbase/SnippetFeed.php'; |
|
48 |
33 |
49 /** |
34 /** |
50 * Service class for interacting with the Google Base data API |
35 * Service class for interacting with the Google Base data API |
51 * |
36 * |
52 * @link http://code.google.com/apis/base |
37 * @link http://code.google.com/apis/base |
53 * |
38 * |
54 * @category Zend |
39 * @category Zend |
55 * @package Zend_Gdata |
40 * @package Zend_Gdata |
56 * @subpackage Gbase |
41 * @subpackage Gbase |
57 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
42 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
58 * @license http://framework.zend.com/license/new-bsd New BSD License |
43 * @license http://framework.zend.com/license/new-bsd New BSD License |
59 */ |
44 */ |
60 class Zend_Gdata_Gbase extends Zend_Gdata |
45 class Zend_Gdata_Gbase extends Zend_Gdata |
61 { |
46 { |
62 |
47 |
63 /** |
48 /** |
64 * Path to the customer items feeds on the Google Base server. |
49 * Path to the customer items feeds on the Google Base server. |
65 */ |
50 */ |
66 const GBASE_ITEM_FEED_URI = 'http://www.google.com/base/feeds/items'; |
51 const GBASE_ITEM_FEED_URI = 'https://www.google.com/base/feeds/items'; |
67 |
52 |
68 /** |
53 /** |
69 * Path to the snippets feeds on the Google Base server. |
54 * Path to the snippets feeds on the Google Base server. |
70 */ |
55 */ |
71 const GBASE_SNIPPET_FEED_URI = 'http://www.google.com/base/feeds/snippets'; |
56 const GBASE_SNIPPET_FEED_URI = 'https://www.google.com/base/feeds/snippets'; |
72 |
57 |
73 /** |
58 /** |
74 * Authentication service name for Google Base |
59 * Authentication service name for Google Base |
75 */ |
60 */ |
76 const AUTH_SERVICE_NAME = 'gbase'; |
61 const AUTH_SERVICE_NAME = 'gbase'; |
77 |
|
78 /** |
|
79 * The default URI for POST methods |
|
80 * |
|
81 * @var string |
|
82 */ |
|
83 protected $_defaultPostUri = self::GBASE_ITEM_FEED_URI; |
|
84 |
|
85 /** |
|
86 * Namespaces used for Zend_Gdata_Gbase |
|
87 * |
|
88 * @var array |
|
89 */ |
|
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) |
|
93 ); |
|
94 |
62 |
95 /** |
63 /** |
96 * Create Zend_Gdata_Gbase object |
64 * Create Zend_Gdata_Gbase object |
97 * |
65 * |
98 * @param Zend_Http_Client $client (optional) The HTTP client to use when |
66 * @param Zend_Http_Client $client (optional) The HTTP client to use when |
99 * when communicating with the Google Apps servers. |
67 * when communicating with the Google Apps servers. |
100 * @param string $applicationId The identity of the app in the form of Company-AppName-Version |
68 * @param string $applicationId The identity of the app in the form of Company-AppName-Version |
101 */ |
69 */ |
102 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0') |
70 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0') |
103 { |
71 { |
104 $this->registerPackage('Zend_Gdata_Gbase'); |
72 throw new Zend_Exception( |
105 $this->registerPackage('Zend_Gdata_Gbase_Extension'); |
73 'Google Base API has been discontinued by Google and was removed' |
106 parent::__construct($client, $applicationId); |
74 . ' from Zend Framework in 1.12.0. For more information see: ' |
107 $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME); |
75 . 'http://googlemerchantblog.blogspot.ca/2010/12/new-shopping-apis-and-deprecation-of.html' |
108 } |
76 ); |
109 |
|
110 /** |
|
111 * Retreive feed object |
|
112 * |
|
113 * @param mixed $location The location for the feed, as a URL or Query |
|
114 * @return Zend_Gdata_Gbase_ItemFeed |
|
115 */ |
|
116 public function getGbaseItemFeed($location = null) |
|
117 { |
|
118 if ($location === null) { |
|
119 $uri = self::GBASE_ITEM_FEED_URI; |
|
120 } else if ($location instanceof Zend_Gdata_Query) { |
|
121 $uri = $location->getQueryUrl(); |
|
122 } else { |
|
123 $uri = $location; |
|
124 } |
|
125 return parent::getFeed($uri, 'Zend_Gdata_Gbase_ItemFeed'); |
|
126 } |
|
127 |
|
128 /** |
|
129 * Retreive entry object |
|
130 * |
|
131 * @param mixed $location The location for the feed, as a URL or Query |
|
132 * @return Zend_Gdata_Gbase_ItemEntry |
|
133 */ |
|
134 public function getGbaseItemEntry($location = null) |
|
135 { |
|
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(); |
|
142 } else { |
|
143 $uri = $location; |
|
144 } |
|
145 return parent::getEntry($uri, 'Zend_Gdata_Gbase_ItemEntry'); |
|
146 } |
|
147 |
|
148 /** |
|
149 * Insert an entry |
|
150 * |
|
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 |
|
154 */ |
|
155 public function insertGbaseItem($entry, $dryRun = false) |
|
156 { |
|
157 if ($dryRun == false) { |
|
158 $uri = $this->_defaultPostUri; |
|
159 } else { |
|
160 $uri = $this->_defaultPostUri . '?dry-run=true'; |
|
161 } |
|
162 $newitem = $this->insertEntry($entry, $uri, 'Zend_Gdata_Gbase_ItemEntry'); |
|
163 return $newitem; |
|
164 } |
|
165 |
|
166 /** |
|
167 * Update an entry |
|
168 * |
|
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 |
|
172 */ |
|
173 public function updateGbaseItem($entry, $dryRun = false) |
|
174 { |
|
175 $returnedEntry = $entry->save($dryRun); |
|
176 return $returnedEntry; |
|
177 } |
|
178 |
|
179 /** |
|
180 * Delete an entry |
|
181 * |
|
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 |
|
185 */ |
|
186 public function deleteGbaseItem($entry, $dryRun = false) |
|
187 { |
|
188 $entry->delete($dryRun); |
|
189 return $this; |
|
190 } |
|
191 |
|
192 /** |
|
193 * Retrieve feed object |
|
194 * |
|
195 * @param mixed $location The location for the feed, as a URL or Query |
|
196 * @return Zend_Gdata_Gbase_SnippetFeed |
|
197 */ |
|
198 public function getGbaseSnippetFeed($location = null) |
|
199 { |
|
200 if ($location === null) { |
|
201 $uri = self::GBASE_SNIPPET_FEED_URI; |
|
202 } else if ($location instanceof Zend_Gdata_Query) { |
|
203 $uri = $location->getQueryUrl(); |
|
204 } else { |
|
205 $uri = $location; |
|
206 } |
|
207 return parent::getFeed($uri, 'Zend_Gdata_Gbase_SnippetFeed'); |
|
208 } |
77 } |
209 } |
78 } |