You can query customer items feed or snippets feed to retrieve items. It involves two steps, sending a query and iterating through the returned feed.
You can send a structured query to retrieve items from your own customer items feed or from the public snippets feed.
When retrieving items using the Base API, specially constructed
query URLs are used to describe what events should be returned.
The Zend_Gdata_Gbase_ItemQuery and
Zend_Gdata_Gbase_SnippetQuery classes simplify this task by
automatically constructing a query URL based on provided
parameters.
To execute a query against the customer items feed, invoke
newItemQuery() and
getGbaseItemFeed() methods:
<?php
$service = new Zend_Gdata_Gbase($client);
$query = $service->newItemQuery();
$query->setBq('[title:Programming]');
$query->setOrderBy('modification_time');
$query->setSortOrder('descending');
$query->setMaxResults('5');
$feed = $service->getGbaseItemFeed($query);
A full list of these parameters is available at the Query parameters section of the Customer Items Feed documentation.
To execute a query against the public snippets feed, invoke
newSnippetQuery() and
getGbaseSnippetFeed() methods:
<?php
$service = new Zend_Gdata_Gbase();
$query = $service->newSnippetQuery();
$query->setBq('[title:Programming]');
$query->setOrderBy('modification_time');
$query->setSortOrder('descending');
$query->setMaxResults('5');
$feed = $service->getGbaseSnippetFeed($query);
A full list of these parameters is available at the Query parameters section of the Snippets Feed documentation.
Google Base items can contain item-specific attributes such as <g:main_ingredient> and <g:weight>.
To iterate through all attributes of a given item, invoke
getGbaseAttributes() and iterate through the results:
<?php
foreach ($feed->entries as $entry) {
// Get all attributes and print out the name and text value of each
// attribute
$baseAttributes = $entry->getGbaseAttributes();
foreach ($baseAttributes as $attr) {
echo "Attribute " . $attr->name . " : " . $attr->text . "<br>";
}
}
Or, you can look for specific attribute name and iterate through the results that match:
<?php
foreach ($feed->entries as $entry) {
// Print all main ingredients <g:main_ingredient>
$baseAttributes = $entry->getGbaseAttribute("main_ingredient");
foreach ($baseAttributes as $attr) {
echo "Main ingredient: " . $attr->text . "<br>";
}
}




