4 messages in com.googlegroups.google-base-data-apiRe: php 5, google attributes yield "p...| Subject: | Re: php 5, google attributes yield "property does not exist" error![]() |
|---|---|
| From: | Jeff S (j....@google.com) |
| Date: | 08/27/2007 02:50:12 PM |
| List: | com.googlegroups.google-base-data-api |
Hi Elliott,
The Zend 1.0 library and above doesn't really support the Google Base API at the moment. The code you posted looks like it was targeted for an older version of the Zend library (version 0.9). I have written a short code snippet which uses the new version of the library.
Even though the library doesn't support elements in the Google Base namespace natively, you can add them as extension elements in an entry. I wrote a function to append a new Google Base extension element to a list.
function addBaseAttribute($name, $value, $entry) { $array = $entry->getExtensionElements(); $new_extension = new Zend_Gdata_App_Extension_Element($name, 'g', 'http://base.google.com/ns/1.0', $value); $array[count($array)] = $new_extension; $entry->setExtensionElements($array); }
You can use this functions as follows:
$entry = $gdClient->newEntry(); addBaseAttribute('item_type', 'vehicles', $entry);
For a full example, take a look at this thread: http://groups.google.com/group/Google-Base-data-API/browse_thread/thread/be344f6e8df17edf
Thank you,
Jeff
On Aug 25, 2:47 pm, Elliott <kell...@gmail.com> wrote:
Hello,
I have been trying to piece together the latest Zend Framework and the recipe demo to make Google Base insertions of the Vehicles item type.
I could find no example, even after following the link which Jeff S gave to evly in the Aug 20 post, of using the latest Zend Gdata classes to post Google attributes.
Here's the first Google attribute. $newEntry->{'g:item_type'} = 'Vehicles';
And the script returned "Property _g:item_type does not exist" in ZendGdata-1.0.1/library/Zend/Gdata/App/Base.php: line 344.
As far as I could tell, Line 344 checks if the attributes are valid, which requires "registering the namespace" for each google attribute. In the recipe demo, this is done by the following line: Zend_Feed::registerNamespace('g', 'http://base.google.com/ns/1.0');
Thus, I see two possible sources of the problem. 1. The syntax for setting Google attributes in a $newEntry object is wrong. This seems unlikely because the error message received the property name, but said it did not exist.
2. The Google attributes are not being properly registered. Perhaps Zend/Feed.php is the wrong file to use to register a namespace in the newer version of the Zend framework. Perhaps the URL used to register namespaces is incorrect.
Or perhaps the problem lies somewhere else entirely.
I would certainly appreciate any help. Let me know if I should paste in any additional code. Thanks, Elliott




