search and update google base with php

30
Search and update Google Base with PHP Use PHP to process and integrate data from Google Base with a custom Web application Skill Level: Intermediate Vikram Vaswani Founder Melonfire 09 Feb 2010 Google Base allows users to store any type of content online in Google's version of a massive online database. Web application developers are able to access and search this content through the Google Base Data API. This article introduces the Google Base Data API and demonstrates it in the context of a PHP application, explaining how to use SimpleXML and the Zend_Gdata module to search, retrieve, add, and edit different types of data on Google Base. Introduction Most search engines work by crawling the Web, indexing and filtering the content they find into massive databases, and searching these databases to find results matching a particular search query. This crawling/indexing process is performed without human intervention, both to maximize efficiency and to avoid biases in data collation and categorization. Frequently used acronyms API: application programming interface CSS: Cascading stylesheets DOM: Document Object Model HTML: HyperText Markup Language Search and update Google Base with PHP © Copyright IBM Corporation 2010. All rights reserved. Page 1 of 30

Upload: others

Post on 12-Sep-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Search and update Google Base with PHP

Search and update Google Base with PHPUse PHP to process and integrate data from Google Base witha custom Web application

Skill Level: Intermediate

Vikram VaswaniFounderMelonfire

09 Feb 2010

Google Base allows users to store any type of content online in Google's version of amassive online database. Web application developers are able to access and searchthis content through the Google Base Data API. This article introduces the GoogleBase Data API and demonstrates it in the context of a PHP application, explaininghow to use SimpleXML and the Zend_Gdata module to search, retrieve, add, andedit different types of data on Google Base.

Introduction

Most search engines work by crawling the Web, indexing and filtering the contentthey find into massive databases, and searching these databases to find resultsmatching a particular search query. This crawling/indexing process is performedwithout human intervention, both to maximize efficiency and to avoid biases in datacollation and categorization.

Frequently used acronyms

• API: application programming interface

• CSS: Cascading stylesheets

• DOM: Document Object Model

• HTML: HyperText Markup Language

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 1 of 30

Page 2: Search and update Google Base with PHP

• HTTP: Hypertext Transfer Protocol

• REST: Representational state transfer

• URL: Uniform Resource Locator

• XML: Extensible Markup Language

That's why Google Base is so unusual. Launched in late 2005, Google Base is anonline database that allows users to directly upload content, tag it with variousdescriptive attributes, and make this information searchable through the mainGoogle search engine. The system has a set of pre-defined item types—forexample, "jobs", "travel", "events" and so on—and it allows users to describe contenteither using these pre-defined types or by creating new ones. Any type of data canbe uploaded, including such random bits of information as your best friend's nameand birthday, when and where the next local "battle of the bands" competition willtake place, and which job opportunities are currently available at your workplace.

Of course, providing online storage for information is just one part of the puzzle; theother part is making it searchable and accessible. Content uploaded to Google Baseis automatically indexed and made publicly available through the Google searchengine. More importantly, Google Base content is also available through the GoogleBase Data API, allowing application developers to search and retrieve thisuser-created content and integrate it into custom applications. This API, whichfollows the REST model, can be accessed through any XML-capable developmenttoolkit, and already has client libraries for many common programming languages,including PHP, .NET, Python and Java ™ technology.

This article will introduce you to the Google Base Data API, showing you how tosearch Google Base for information in a variety of different categories, and integrateand use search results with a custom PHP application. It includes examples ofsearching for data using various attributes, and adding, updating, and deleting datain the system. Come on in, and get started!

Understanding Google Base feeds

Before you start to develop applications with Google Base, you need to understandhow it works. As with all REST-based services, things get rolling with an HTTPrequest to a designated resource. This HTTP request contains a query with one ormore input parameters; the server replies to the query with an Atom feed, suitablefor parsing in any XML-aware client.

To see how this works, try accessing the URL in your favourite Web browser:

http://www.google.com/base/feeds/snippets?

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 2 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 3: Search and update Google Base with PHP

bq=product+manager[itemtype:jobs][location:CA]

Note: For formatting purposes, the preceding URL is split to multiple lines. Use it asa single string. (View the URL as a single string.)

This request returns a list of entries from Google Base—in this case, a list of ProductManager jobs in the state of California. The raw XML response to this method (whichyou can view in the source code of the resulting page) contains detailed informationon each entry, and might look something like Listing 1:

Listing 1. An example Google Base feed

<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'xmlns:gm='http://base.google.com/ns-metadata/1.0'xmlns:g='http://base.google.com/ns/1.0'xmlns:batch='http://schemas.google.com/gdata/batch'><id>http://www.google.com/base/feeds/snippets</id><updated>2010-01-14T06:50:03.819Z</updated><title type='text'>Items matching query:product manager[itemtype:jobs][location:CA]</title>

<link rel='alternate' type='text/html' href='http://base.google.com'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml'href='http://www.google.com/base/feeds/snippets'/>

<link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml'href='http://www.google.com/base/feeds/snippets/batch'/>

<link rel='self' type='application/atom+xml'href='http://www.google.com/base/feeds/snippets?start-index=1&max-results=25&bq=product+manager%5Bitemtype%3Ajobs%5D%5Blocation%3ACA%5D'/>

<link rel='next' type='application/atom+xml'href='http://www.google.com/base/feeds/snippets?start-index=26&max-results=25&bq=product+manager%5Bitemtype%3Ajobs%5D%5Blocation%3ACA%5D'/>

<author><name>Google Inc.</name><email>[email protected]</email>

</author><generator version='1.0' uri='http://base.google.com'>GoogleBase</generator><openSearch:totalResults>11299</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry>

<id>http://www.google.com/base/feeds/snippets/6996651848910375403</id><published>2010-01-08T12:57:46.000Z</published><updated>2010-01-13T12:31:03.000Z</updated><category scheme='http://base.google.com/categories/itemtypes' term='Jobs'/><title type='text'>SR. PRODUCT MANAGER: Internet Video Markets</title><content type='html'>As a SR. PRODUCT MANAGER, you're a take-charge person.A born leader. A people person who sees the big picture, as well as the minutedetails. You generate powerful ideas and know how to get them implemented.If this describesyou, you'll want to ...</content><link rel='alternate' type='text/html'href='http://www.net-temps.com/job/37zk/USA_5192/sr_product_manager_internet.html?r=goo'/>

<link rel='self' type='application/atom+xml'href='http://www.google.com/base/feeds/snippets/6996651848910375403'/>

<author><name>Net-Temps</name>

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 3 of 30

Page 4: Search and update Google Base with PHP

</author><g:job_function type='text'>Marketing</g:job_function><g:location type='location'>San Francisco, CA, us</g:location><g:employer type='text'>Manpower</g:employer><g:label type='text'>analysis</g:label><g:label type='text'>business</g:label><g:label type='text'>product</g:label><g:label type='text'>access</g:label><g:label type='text'>management</g:label><g:label type='text'>marketing</g:label><g:label type='text'>manager</g:label><g:label type='text'>temporary job</g:label><g:label type='text'>temp</g:label><g:education type='text'>masters</g:education><g:education type='text'>bachelors</g:education><g:item_language type='text'>EN</g:item_language><g:id type='text'>1237852</g:id><g:job_type type='text'>contract</g:job_type><g:job_type type='text'>contractor</g:job_type><g:target_country type='text'>US</g:target_country><g:expiration_date type='dateTime'>2010-01-20T12:31:03Z</g:expiration_date><g:job_industry type='text'>Marketing</g:job_industry><g:customer_id type='int'>1106811</g:customer_id><g:item_type type='text'>Jobs</g:item_type>

</entry>...

</feed>

Like other Google APIs, the Google Base Data API responds to REST requests withan Atom feed containing the requested data. There are two main feeds of interest: apublic feed (the snippets feed), which contains a list of all Google Base items, and aprivate feed, which contains a list of items uploaded by a specific user. The former ispublicly accessible and searchable; the latter is only available to the feed owner aftersuccessful authentication. This article will discuss both feeds.

Listing 1 illustrates an example of the snippets feed, generated in response to asearch request for Product Manager jobs in California. This is a standard Atom feed,with the outermost <feed> element containing <link> elements with URLs for thecurrent, next, and previous pages of the result set, and <openSearch:> elementswith summary statistics for the search.

The outermost <feed> element also encloses one or more <entry> elements, eachrepresenting a result item matching the search query. Each entry containsdescriptive metadata, including a title, a block of text or HTML content, and a URLfor more information. Each <entry> also contains <link> elements, which provideURL links to related information.

Perhaps most importantly, each entry includes a set of attributes (the <g:>namespaced elements) containing additional information relevant to the item type.Google Base offers a number of pre-defined item types, with recommendedattributes for each. These attributes are important for two reasons: from a publisherperspective, they make it possible to tag or mark up each entry with additionaldescriptive information and, from a user perspective, they can be used to filtersearch results.

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 4 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 5: Search and update Google Base with PHP

To understand this better, look at the URL used to generate Listing 1. Thelocation and itemtype attributes included in the request URL serve as filters, torestrict the result set to only those entries that belong to the jobs item type and aretagged with the state code CA for location.

The information requirements for job listings is, of course, very different from theinformation requirements for, say, event listings or real estate listings. So it's worthpointing out that the list of attributes available differs for each item type supported byGoogle Base. For example, the jobs item type incorporates attributes such aslocation, employer, education, and salary, while the recipes item type incorporatesattributes such as course, ingredients, number of servings and preparation time. TheGoogle Base Data API Reference Guide includes a discussion of how to obtain acomplete list of item types and suggested attributes for each (see Resources for alink).

Parsing Google Base feeds with SimpleXML

With this background information out of the way, look at integrating Google Basedata with a PHP application. The simplest (pardon the pun) way to do this is withPHP's SimpleXML extension, which provides an object-oriented API to access dataencoded in XML. If you prefer, you can also use PHP's DOM or XMLReaderextensions to perform the same task. To illustrate, consider Listing 2, which usesSimpleXML to parse the XML feed in Listing 1 and convert the data encoded within itto a Web page:

Listing 2. Parsing a Google Base feed with SimpleXML

<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>

<title>Retrieving Google Base snippets</title><style type="text/css">.title {font-weight: holder;

}.attr {margin-left: 15px;

}.result {margin-bottom: 5px;float: left;width: 450px;margin-left: 20px;

}</style>

</head><body>

<?php// define snippet feed URL$url = 'http://www.google.com/base/feeds/snippets?bq=product+manager[itemtype:jobs][location:CA]';

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 5 of 30

Page 6: Search and update Google Base with PHP

// get feed XML and load into SimpleXML object$sxml = simplexml_load_file($url);

// get summary counts from opensearch: namespace$counts = $sxml->children('http://a9.com/-/spec/opensearchrss/1.0/');$total = $counts->totalResults;?>

<h2><?php echo $sxml->title; ?></h2><div id="summary"><?php echo $total; ?> result(s) found.

</div>

<br/>

<div id="results")<?php $count = 1; ?><?php foreach ($sxml->entry as $entry): ?>

<?php// iterate over attributes// get employer, location, industry and type$attrs = $entry->children('http://base.google.com/ns/1.0');$valsEmployer = array();$valsLocation = array();$valsIndustry = array();$valsEducation = array();$valsType = array();foreach ($attrs as $key => $value) {

switch ($key) {case 'employer':

$valsEmployer[] = $value;break;

case 'location':$valsLocation[] = $value;break;

case 'job_industry':$valsIndustry[] = $value;break;

case 'job_type':$valsType[] = $value;break;

case 'education':$valsEducation[] = $value;break;

}}

?>

<div class="result"><div class="title"><?php echo $count; ?>.<?php echo $entry->title; ?>

</div><div class="attr">Employer: <?php echo implode(', ', $valsEmployer); ?> <br/>Location: <?php echo implode(', ', $valsLocation); ?> <br/>Industry: <?php echo implode(', ', $valsIndustry); ?> <br/>Type: <?php echo implode(', ', $valsType); ?> <br/>Education: <?php echo implode(', ', $valsEducation); ?> <br/></div>

</div><?php $count++; ?><?php endforeach; ?>

</div>

</body></html>

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 6 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 7: Search and update Google Base with PHP

Figure 1 demonstrates the output you might see. (View a text-only version of Figure1.)

Figure 1. The results of a Google Base search using SimpleXML

Listing 2 begins by using the simplexml_load_file() object to send a requestto the feed URL and convert the response into a SimpleXML object. It then iteratesover the <entry> elements in the response, processing each one using aforeach() loop. For each entry, attributes are stored in the <g:element> nodecollection. SimpleXML's children() method is used in conjunction with the g:namespace to return this node collection as a SimpleXMLElement object named$attrs.

It now becomes possible to retrieve individual attributes and values from this object

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 7 of 30

Page 8: Search and update Google Base with PHP

using SimpleXML. For example, the job location, which is stored in the <g:location>element for each entry', is accessible as $attrs->location associative array.This information is then combined into a composite HTML page, with some simpleCSS styling to make it usable.

Parsing Google Base feeds with Zend_Gdata

A second technique for parsing the Google Base feeds involves dropping the entiremanual-feed-parsing-with-SimpleXML in favour of the Zend Framework'sZend_Gdata client library, which is designed specifically for developers trying tointegrate PHP applications with Google Data APIs.

You can download the Zend_Gdata library either as part of the Zend Framework oras a stand-alone package (see Resources for a link). It includes a modulespecifically for working with the Google Base Data API, providing pre-definedclasses and methods to simplify data access and authentication. Not only does thislibrary provide a solid, community-tested codebase for your application, but using italso allows you to focus on core application functions, rather than on the details ofnavigating XML trees or handling custom namespaces.

Listing 3 illustrates the Zend_Gdata client library in action, using it to produce aresult equivalent to that of Listing 2:

Listing 3. Parsing a Google Base feed with Zend_Gdata

<?php// load Zend Gdata librariesrequire_once 'Zend/Loader.php';Zend_Loader::loadClass('Zend_Gdata_Gbase');Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

try {// initialize service object// no authentication needed for public snippets feed$service = new Zend_Gdata_Gbase();

// prepare and execute search query on snippets feed$query = $service->newSnippetQuery();$query->setBq('product manager[location:CA][itemtype:jobs]');$feed = $service->getGbaseSnippetFeed($query);

} catch (Exception $e) {die('ERROR:' . $e->getMessage());

}?><!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>

<title>Retrieving Google Base snippets</title><style type="text/css">.title {font-weight: bolder;

}

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 8 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 9: Search and update Google Base with PHP

.attr {margin-left: 15px;

}.result {margin-bottom: 5px;float: left;width: 450px;margin-left: 20px;

}</style>

</head><body>

<h2><?php echo $feed->title; ?></h2><div id="summary"><?php echo $feed->totalResults; ?> result(s) found.</div>

<br/>

<div id="results")<?php $count = 1; ?><?php foreach ($feed as $entry): ?>

<?php// iterate over attributes// get employer, location, industry, education and type$valsEmployer = array();$valsLocation = array();$valsIndustry = array();$valsType = array();$valsEducation = array();foreach ($entry->getGbaseAttributes() as $attr) {

if ($attr->getText()) {switch ($attr->getName()) {

case 'employer':$valsEmployer[] = $attr->getText();break;

case 'location':$valsLocation[] = $attr->getText();break;

case 'job_industry':$valsIndustry[] = $attr->getText();break;

case 'job_type':$valsType[] = $attr->getText();break;

case 'education':$valsEducation[] = $attr->getText();break;

}}

}?>

<div class="result"><div class="title"><?php echo $count; ?>.<a href="<?php echo $entry->getLink('alternate')->getHref(); ?>">

<?php echo $entry->getTitle(); ?></a>

</div><div class="attr">Employer: <?php echo implode(', ', $valsEmployer); ?> <br/>Location: <?php echo implode(', ', $valsLocation); ?> <br/>Industry: <?php echo implode(', ', $valsIndustry); ?> <br/>Type: <?php echo implode(', ', $valsType); ?> <br/>Education: <?php echo implode(', ', $valsEducation); ?> <br/>

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 9 of 30

Page 10: Search and update Google Base with PHP

</div></div><?php $count++; ?><?php endforeach; ?>

</div>

</body></html>

Listing 3 first loads the Zend class libraries, and then initializes an instance of theZend_Gdata_Gbase service class. This class serves as the control point for allsubsequent interactions with the Google Base Data API. Since the current plan is toonly access the public snippets feed, no authentication credentials are needed bythe service object; however, this will change once you start to work with the user'sprivate feed (later in this article).

The Zend_Gdata_Base method that you're most likely to use with the public snippetsfeed is the getGbaseSnippetFeed() method, which returns a feed of itemsmatching a search query. This method is passed an instance of a configuredZend_Gdata_Gbase_SnippetQuery object, with the query string set through thesetBq() class method. The response to the getGbaseSnippetFeed() method isan Atom feed similar to the one displayed in Listing 1; this feed is automaticallyparsed and converted into an array of Zend_Gdata_Gbase_SnippetEntry objects,each representing one <entry> in the feed.

The individual attributes of each entry are represented asZend_Gdata_Gbase_Extension_BaseAttribute objects, each of which exposesgetName() and getText() methods. You can obtain a complete collection ofthese attributes with the getGbaseAttributes() of the methodZend_Gdata_Gbase_SnippetEntry object. It is now quite simple to iterate over thiscollection, extract the values needed, and display them in an HTML page. Noticealso the getLink() method, which returns a link to third-party URL of each entry.

Figure 2 shows the output of Listing 3. (View a text-only version of Figure 2.)

Figure 2. The results of a Google Base search using Zend_Gdata

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 10 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 11: Search and update Google Base with PHP

With this basic understanding in place, it's quite easy to modify Listing 3 to make itmore interactive. Listing 4 demonstrates, adding a search form that can be used tosearch different item types for matches to user-supplied keywords:

Listing 4. Searching Google Base with user-supplied criteria

<?phpif (isset($_POST['submit'])) {// load Zend Gdata librariesrequire_once 'Zend/Loader.php';Zend_Loader::loadClass('Zend_Gdata_Gbase');Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

try {// initialize service object// no authentication needed for public snippets feed$service = new Zend_Gdata_Gbase();

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 11 of 30

Page 12: Search and update Google Base with PHP

// prepare and execute search query on snippets feed$query = $service->newSnippetQuery();$queryStr = $_POST['q'] . '[itemtype:' . $_POST['itemtype'] . ']';$query->setBq($queryStr);$feed = $service->getGbaseSnippetFeed($query);

} catch (Exception $e) {die('ERROR:' . $e->getMessage());

}}?><!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>

<title>Searching Google Base snippets</title><style type="text/css">.title {font-weight: bolder;

}.attr {border-collapse: collapse;margin-top: 3px;

}.result {margin-bottom: 5px;float: left;width: 450px;margin-left: 10px;

}</style>

</head><body>

<h2>Search</h2><form method="post">Search for:<input type="text" name="q" />in section:<select name="itemtype"><option value="events and activities">Events</option><option value="housing">Housing</option><option value="jobs">Jobs</option><option value="news and articles">News</option><option value="personals">Personals</option><option value="recipes">Recipes</option><option value="reviews">Reviews</option><option value="services">Services</option>

</select><input type="submit" name="submit" value="Search" /></form>

<?php if (isset($feed)): ?><h2><?php echo $feed->title; ?></h2><div id="summary"><?php echo $feed->totalResults; ?> result(s) found.</div>

<br/>

<div id="results")<?php $count = 1; ?><?php foreach ($feed as $entry): ?><div class="result">

<div class="title"><?php echo $count; ?>.<a href="<?php echo $entry->getLink('alternate')->getHref(); ?>">

<?php echo $entry->getTitle(); ?>

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 12 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 13: Search and update Google Base with PHP

</a></div><table border="1" class="attr"><?php /* get and display all attributes */ ?><?php /* convert hyperlinks using preg */ ?><?php foreach ($entry->getGbaseAttributes() as $attr): ?><?php if ($attr->getText()): ?>

<tr><td><?php echo strtoupper($attr->getName()); ?></td><td><?php echo (preg_match('/^(http(s?)):/',$attr->getText())) ?'<a href="' . $attr->getText(). '">click here</a>' :substr($attr->getText(), 0, 50); ?></td>

</tr><?php endif; ?>

<?php endforeach; ?></table>

</div><?php $count++; ?><?php endforeach; ?>

</div><?php endif; ?>

</body></html>

This script looks complicated, but have no fear, it' simpler than it appears. It beginsby setting up a form with a search input field and an (abridged) list of Google Baseitem types. Based on the input entered by the user, it then generates aZend_Gdata_Gbase_SnippetQuery object and passes this to thegetGbaseSnippetFeed() method to obtain a result feed matching the inputparameters. Each entry in the result feed is then processed, and the attributes foreach entry are displayed through the getGbaseAttributes() method.

Figure 3 demonstrates an example of the output generated by a search for reviewscontaining the keyword 'wine':

Figure 3. The results of a Google Base search for reviews containing thekeyword 'wine'

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 13 of 30

Page 14: Search and update Google Base with PHP

Filtering Google Base search results

As you've seen in previous examples, it's possible to filter the search resultsreturned by Google Base, simply by using attribute as query filters. These attributesare typically enclosed in square parentheses, as illustrated in the following

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 14 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 15: Search and update Google Base with PHP

examples:

• Product manager jobs in California:

http://www.google.com/base/feeds/snippets?bq=product+manager[itemtype:jobs][location:CA]

• Recipes containing bacon:

http://www.google.com/base/feeds/snippets?bq=[itemtype:recipes][ingredients:bacon]

• Modern art exhibitions in New York City:

http://www.google.com/base/feeds/snippets?bq=modern+art[itemtype:events%20and%20activities][location:new%20york]

Note: For formatting purposes, the preceding URLs are split to multiple lines. Usethe URLs as a single string. (View the URLs as a single string.)

Apart from this, you can easily customize the API output by adding some of thefollowing parameters to your REST query:

• The start-index parameter, which specifies the start offset for theentries in a feed

• The max-results parameter, which specifies the number of entries in afeed

• The q parameter, which can be used for full-text searches

• The crowdby parameter, which controls how often items with a specifiedattribute value are repeated

• The orderby parameter, which specifies how to sort results

Listing 5 has examples of these parameters in action:

Listing 5. Filtering Google Base search results

<?phpif (isset($_POST['submit'])) {// load Zend Gdata librariesrequire_once 'Zend/Loader.php';Zend_Loader::loadClass('Zend_Gdata_Gbase');Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

try {

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 15 of 30

Page 16: Search and update Google Base with PHP

// initialize service object// no authentication needed for public snippets feed$service = new Zend_Gdata_Gbase();

// prepare and execute search query on snippets feed// attach attribute filters$query = $service->newSnippetQuery();$queryStr = $_POST['q'] . '[itemtype:events and activities]';if (!empty($_POST['location'])) {$queryStr .= '[location: '. $_POST['location'] . ']';

}if (!empty($_POST['event_type'])) {$queryStr .= '[event_type: '. $_POST['type'] .']';

}

// display 20 results per page// crowd by content field$query->setBq($queryStr);$query->setMaxResults(20);$query->setCrowdBy('content:2');$feed = $service->getGbaseSnippetFeed($query);

} catch (Exception $e) {die('ERROR:' . $e->getMessage());

}}?><!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>

<title>Searching Google Base snippets</title><style type="text/css">.title {font-weight: bolder;

}.attr {border-collapse: collapse;margin-top: 3px;

}.result {margin-bottom: 5px;float: left;width: 450px;margin-left: 10px;

}</style>

</head><body>

<h2>Search Events</h2><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">Keywords:<input type="text" name="q" />

Location:<input type="text" name="location" size="10" />

Event type:<input type="text" name="type" size="10" />

<input type="submit" name="submit" value="Search" /></form>

<?php if (isset($feed)): ?><h2><?php echo $feed->title; ?></h2><div id="summary"><?php echo $feed->totalResults; ?> result(s) found.</div>

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 16 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 17: Search and update Google Base with PHP

<br/>

<div id="results")<?php $count = 1; ?><?php foreach ($feed as $entry): ?><div class="result">

<div class="title"><?php echo $count; ?>.<a href="<?php echo $entry->getLink('alternate')->getHref(); ?>">

<?php echo $entry->getTitle(); ?></a>

</div><table border="1" class="attr"><?php /* get and display all attributes */ ?><?php // convert hyperlinks using preg */ ?><?php foreach ($entry->getGbaseAttributes() as $attr): ?><?php if ($attr->getText()): ?>

<tr><td><?php echo strtoupper($attr->getName()); ?></td><td><?php echo (preg_match('/^(http(s?)):/',$attr->getText())) ?'<a href="' . $attr->getText(). '">click here</a>' :substr($attr->getText(), 0, 50); ?></td>

</tr><?php endif; ?>

<?php endforeach; ?></table>

</div><?php $count++; ?><?php endforeach; ?>

</div><?php endif; ?>

</body></html>

Listing 5 generates a simple event search form, with fields for event keywords,location, and type. These inputs are then converted into the corresponding attributesand appended to the Google Base query. The setMaxResults() method is usedto control the number of results displayed in the feed, while the setCrowdBy()method defines the control attribute and value for repetition (in this case, only twoduplicate entries with the same content will be allowed).

Figure 4 displays an example of a search for modern art exhibitions in New York:

Figure 4. The results of a filtered Google Base event search

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 17 of 30

Page 18: Search and update Google Base with PHP

Adding items to Google Base

The previous examples have all operated with the public snippets feed. However, asyou might remember, every authenticated user also has access to a private feed,which contains the user's own additions to Google Base. The Google Base Data APIprovides programmatic access to this feed, allowing users to add, edit, and deleteitems using API calls. The following sections examine this in detail.

First up, adding new items. This is actually quite simple: to add a new entry, simplyPOST an XML-encoded <entry> block to the private feed URL. Listing 6 has anexample of one such block:

Listing 6. An example Google Base entry block

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 18 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 19: Search and update Google Base with PHP

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"><atom:title type="text">Chicken Tikka Masala</atom:title><atom:content type="text">Cut the chicken into fine pieces. Fry until golden.Add onions, spices and fry for 4-5 minutes and golden. Add chopped tomatoes,curd and seasoning. Allow to simmer for 10 minutes.</atom:content>

<item_type xmlns="http://base.google.com/ns/1.0" type="text">recipes</item_type><main_ingredient xmlns="http://base.google.com/ns/1.0" type="text">

chicken</main_ingredient><servings xmlns="http://base.google.com/ns/1.0" type="int">4</servings><cooking_time xmlns="http://base.google.com/ns/1.0" type="number">30</cooking_time><author xmlns="http://base.google.com/ns/1.0" type="text">Mr. Fantastic Cook</author><ingredients xmlns="http://base.google.com/ns/1.0" type="text">chicken</ingredients><ingredients xmlns="http://base.google.com/ns/1.0" type="text">onions</ingredients><ingredients xmlns="http://base.google.com/ns/1.0" type="text">tomatoes</ingredients><ingredients xmlns="http://base.google.com/ns/1.0" type="text">turmeric</ingredients><ingredients xmlns="http://base.google.com/ns/1.0" type="text">coriander</ingredients><ingredients xmlns="http://base.google.com/ns/1.0" type="text">curd</ingredients><ingredients xmlns="http://base.google.com/ns/1.0" type="text">mustard seeds</ingredients>

</atom:entry>

Since the private feed is, by definition, private, any operation on the data containedin the feed will only be successful if the operation is authenticated with the feedowner's username and password using one of the two Google-approvedauthentication methods: AuthSub or ClientLogin. Performing this type ofauthentication manually is a fairly messy task, and requires a fair bit of code toaccount for the various scenarios that might crop up during a typical authenticationtransaction.

Fortunately, you don't have to worry too much about this: the Zend_GData ClientLibrary handles all the details for you. Consider Listing 7, which illustrates how toadd a new item to the private feed:

Listing 7. Adding entries to Google Base

<?php// load Zend Gdata librariesrequire_once 'Zend/Loader.php';Zend_Loader::loadClass('Zend_Gdata_Gbase');Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

// set credentials for ClientLogin authentication$user = "[email protected]";$pass = "secret";

try {// perform login// initialize service object$client = Zend_Gdata_ClientLogin::getHttpClient(

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 19 of 30

Page 20: Search and update Google Base with PHP

$user, $pass, 'gbase');$service = new Zend_Gdata_Gbase($client);

// initialize new item// set title, content and type$item = $service->newItemEntry();$item->setItemType('recipes');$item->title = new Zend_Gdata_App_Extension_Title('Chicken Tikka Masala');$item->content = new Zend_Gdata_App_Extension_Content('Cut the chicken into fine pieces. Fry until golden. Add onions,spices and fry for 4-5 minutes and golden. Add chopped tomatoes,curd and seasoning. Allow to simmer for 10 minutes.');

// set type attributes$item->addGbaseAttribute('main_ingredient', 'chicken', 'text');$item->addGbaseAttribute('servings', '4', 'int');$item->addGbaseAttribute('cooking_time', '30', 'number');$item->addGbaseAttribute('author', 'Mr. Fantastic Cook', 'text');$item->addGbaseAttribute('ingredients', 'chicken', 'text');$item->addGbaseAttribute('ingredients', 'onions', 'text');$item->addGbaseAttribute('ingredients', 'tomatoes', 'text');$item->addGbaseAttribute('ingredients', 'turmeric', 'text');$item->addGbaseAttribute('ingredients', 'coriander', 'text');$item->addGbaseAttribute('ingredients', 'curd', 'text');$item->addGbaseAttribute('ingredients', 'mustard seeds', 'text');

// save to server$entry = $service->insertGbaseItem($item);

// display success messageecho "Entry added successfully with ID: " . $entry->getId();

} catch (Exception $e) {die('ERROR:' . $e->getMessage());

}?>

Listing 7 begins by loading the Zend class libraries, and then initializing an instanceof the Zend_Gdata service class. Unlike what you've seen earlier, this class nowmakes use of a Zend_Http_Client object, which is provided with the necessary userauthentication information and used to open an authenticated connection to theGoogle Base service.

Once an authenticated connection is opened, the service object's newItemEntry()method is used to initialize an instance of the Zend_Gdata_Gbase_ItemEntry class,and the setItemType() method of the entry object is used to define the item type.The title and content of the entry are also set, as instances of theZend_Gdata_App_Extension_Title and Zend_Gdata_App_Extension_Contentclasses, and individual attributes are assigned through the entry object'saddGbaseAttribute() method. Once the entry is complete, the entire thing isposted to the Google Base servers through a call to the service object'sinsertGbaseItem() method.

Once the entry has been successfully posted, you should be presented with a resultpage that contains the new entry ID. Figure 5 has an example of one such resultpage:

Figure 5. The result of successfully adding an item to Google Base

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 20 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 21: Search and update Google Base with PHP

The entry will now also appear in your Google Base account. Figure 6 has anexample of what you might see. (See a larger version of Figure 6.)

Figure 6. The newly-added item, shown in the Google Base interface

Editing and deleting items on Google Base

The Google Base Data API also permits entry editing and deletion. To delete anentry, send a DELETE request to the entry URL, which is the URL specified in theentry's <link rel="self" ...> element. In the Zend library context, you can simply pass

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 21 of 30

Page 22: Search and update Google Base with PHP

this URL to the Zend_Gdata_Gbase_ItemEntry object's delete() method, as inListing 8:

Listing 8. Deleting entries from Google Base

<?php// load Zend Gdata librariesrequire_once 'Zend/Loader.php';Zend_Loader::loadClass('Zend_Gdata_Gbase');Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

// set credentials for ClientLogin authentication$user = "[email protected]";$pass = "secret";

try {// perform login// initialize service object$client = Zend_Gdata_ClientLogin::getHttpClient(

$user, $pass, 'gbase');$service = new Zend_Gdata_Gbase($client);

// get and delete entry$id = 'http://www.google.com/base/feeds/items/1256392227904491772';$entry = $service->getGbaseItemEntry($id);$entry->delete();

// display success messageecho "Entry deleted successfully with ID: " . $entry->getId();

} catch (Exception $e) {die('ERROR:' . $e->getMessage());

}?>

In a similar vein, to edit an entry, use the getGbaseItemEntry() method toretrieve the entry using its unique URL, change the values you wish to update, andthen save the entry back to the server using the Zend_Gdata_Gbase_ItemEntryobject's save() method, which sends a PUT request to the URL specified in theentry's <link rel="self" ...> element. Listing 9 illustrates the process:

Listing 9. Updating entries on Google Base

<?php// load Zend Gdata librariesrequire_once 'Zend/Loader.php';Zend_Loader::loadClass('Zend_Gdata_Gbase');Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

// set credentials for ClientLogin authentication$user = "[email protected]";$pass = "secret";

try {// perform login// initialize service object$client = Zend_Gdata_ClientLogin::getHttpClient(

$user, $pass, 'gbase');$service = new Zend_Gdata_Gbase($client);

// get entry

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 22 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 23: Search and update Google Base with PHP

$id = 'http://www.google.com/base/feeds/items/11812821492318418471';$item = $service->getGbaseItemEntry($id);

// set new title$item->title = new Zend_Gdata_App_Extension_Title('Spaghetti Amatriciana');

// set new content$item->content = new Zend_Gdata_App_Extension_Content('Cutthe bacon into thin strips and fry. Chop the onions and chillies and fry.Add the bacon and tomato puree to the mixture. Simmer for 10 minutes,then drain the pasta and mix.');

// remove existing attributes// set new onesforeach ($item->getGbaseAttributes() as $attr) {

$item->removeGbaseAttribute($attr);}$item->setItemType('recipes');$item->addGbaseAttribute('main_ingredient', 'pasta', 'text');$item->addGbaseAttribute('servings', '4', 'int');$item->addGbaseAttribute('cooking_time', '30', 'number');$item->addGbaseAttribute('author', 'Mr. Fantastic Cook', 'text');$item->addGbaseAttribute('ingredients', 'bacon', 'text');$item->addGbaseAttribute('ingredients', 'onions', 'text');$item->addGbaseAttribute('ingredients', 'tomatoes', 'text');$item->addGbaseAttribute('ingredients', 'green chillies', 'text');$item->addGbaseAttribute('ingredients', 'pasta', 'text');$item->addGbaseAttribute('ingredients', 'tomato puree', 'text');

// save changes to server$item->save();

// display success messageecho "Entry updated successfully with ID: " . $item->getId();

} catch (Exception $e) {die('ERROR:' . $e->getMessage());

}?>

In Listing 9, the entry is first retrieved using its unique ID, and assigned a new titleand content. The existing attributes are removed with theremoveGbaseAttribute() method, and a new set of attributes are assigned. Theresulting entry object is then saved back to Google Base with the same ID.

A simple application

As the previous listings illustrate, it is quite easy to add, delete, and update items onGoogle Base using the Google Base Data API. This section will build a simple PHPapplication around these functions, allowing users to add and delete event listingsusing the Google Base Data API.

Listing 10, which is based on Listing 7, creates a form to add new event listings andthen submits the form data for addition to Google Base:

Listing 10. Adding event entries to a user's private Google Base feed

<?php if (isset($_POST['submit'])) {

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 23 of 30

Page 24: Search and update Google Base with PHP

// load Zend Gdata librariesrequire_once 'Zend/Loader.php';Zend_Loader::loadClass('Zend_Gdata_Gbase');Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

// set credentials for ClientLogin authentication$user = "[email protected]";$pass = "secret";

try {// perform login// initialize service object$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, 'gbase');

$service = new Zend_Gdata_Gbase($client);

//// perform input validation here// omitted for clarity//

// initialize new item// set title, content and type$item = $service->newItemEntry();$item->setItemType('events and activities');$item->title = new Zend_Gdata_App_Extension_Title($_POST['title']);$item->content = new Zend_Gdata_App_Extension_Content($_POST['content']);

// set type attributesforeach ($_POST['attr'] as $key => $value) {$item->addGbaseAttribute($key, $value);

}

// set date range$start = date('c', strtotime($_POST['start']));$item->addGbaseAttribute('event_date_range', $start);

// save to server$entry = $service->insertGbaseItem($item);

// display success messageecho "Entry added successfully with ID: " . $entry->getId();echo '<br/>';echo '<a href="list.php">Back to list</a>';

} catch (Exception $e) {die('ERROR:' . $e->getMessage());

}} else {?><!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>

<title>Adding events to Google Base</title></head><body>

<h2>Add Event</h2><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"><p>Title: <br/><input type="text" name="title" />

</p>

<p>Description: <br/><textarea name="content"></textarea>

</p>

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 24 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 25: Search and update Google Base with PHP

<p>Venue: <br/><input type="text" name="attr[venue]" />

</p>

<p>Address: <br/><input type="text" name="attr[location]" />

</p>

<p>Type: <br/><input type="text" name="attr[event_type]" />

</p>

<p>Start date/time (dd-mm-yyyy hh:mm): <br/><input type="text" name="start" />

</p>

<input type="submit" name="submit" value="Submit" /></form>

</body></html><?php}?>

Listing 11 contains the code to query the user's private feed and retrieve all theentries stored within it. Event entries are displayed in a list, together with venue anddate information. Each entry also has a Delete link, which points to the script inListing 12:

Listing 11. Listing event entries in a user's private Google Base feed

<?php// load Zend Gdata librariesrequire_once 'Zend/Loader.php';Zend_Loader::loadClass('Zend_Gdata_Gbase');Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

// set credentials for ClientLogin authentication$user = "[email protected]";$pass = "secret";

try {// perform login// initialize service object$client = Zend_Gdata_ClientLogin::getHttpClient(

$user, $pass, 'gbase');$service = new Zend_Gdata_Gbase($client);

// get item feed$feed = $service->getGbaseItemFeed();

} catch (Exception $e) {die('ERROR:' . $e->getMessage());

}?><!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 25 of 30

Page 26: Search and update Google Base with PHP

<title>Listing events on Google Base</title><style type="text/css">.title {font-weight: bolder;

}.attr {margin-left: 15px;

}.result {margin-bottom: 5px;float: left;width: 450px;margin-left: 20px;

}</style>

</head><body>

<h2>List Events</h2><a href="add.php">Add a new event</a><br/> <br/>

<div id="results"><?php $count = 1; ?><?php foreach ($feed as $entry): ?>

<?php if ($entry->getItemtype() == 'events and activities'): ?><?php// iterate over attributes// get required dataforeach ($entry->getGbaseAttributes() as $attr) {if ($attr->getText()) {

switch ($attr->getName()) {case 'location':

$location = $attr->getText();break;

case 'venue':$venue = $attr->getText();break;

case 'event_date_range':$date = $attr->getText();break;

case 'event_type':$type = $attr->getText();break;

}}

}?>

<div class="result"><div class="title">

<?php echo $count; ?>.<?php echo $entry->getTitle(); ?>(<a href="delete.php?url=<?php echo $entry->getSelfLink()->getHref(); ?>">delete</a>)

</div><div class="attr">Description: <?php echo $entry->getContent(); ?> <br/>Venue: <?php echo (!empty($venue)) ? $venue :'Unspecified'; ?> <br/>

Address: <?php echo (!empty($location)) ? $location :'Unspecified'; ?> <br/>

Type: <?php echo (!empty($type)) ? $type :'Unspecified'; ?> <br/>

Date/time: <?php echo (!empty($date)) ?date('d-m-Y h:i', strtotime($date)) : 'Unspecified'; ?> <br/>

</div></div>

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 26 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 27: Search and update Google Base with PHP

<?php $count++; ?><?php endif; ?>

<?php endforeach; ?></div>

</html>

Listing 12 accepts an entry's URL and uses the technique shown earlier in Listing 7to delete it from Google Base:

Listing 12. Deleting event entries from a user's private Google Base feed

<?php// load Zend Gdata librariesrequire_once 'Zend/Loader.php';Zend_Loader::loadClass('Zend_Gdata_Gbase');Zend_Loader::loadClass('Zend_Gdata_ClientLogin');

// set credentials for ClientLogin authentication$user = "[email protected]";$pass = "secret";

try {// perform login// initialize service object$client = Zend_Gdata_ClientLogin::getHttpClient(

$user, $pass, 'gbase');$service = new Zend_Gdata_Gbase($client);

// get and delete entry$id = $_GET['url'];$entry = $service->getGbaseItemEntry($id);$entry->delete();

// display success messageecho "Entry deleted successfully with ID: " . $entry->getId();echo '<br/>';echo '<a href="list.php">Back to list</a>';

} catch (Exception $e) {die('ERROR:' . $e->getMessage());

}?>

Conclusion

Over the last few pages, you got a crash course in how to integrate data from theGoogle Base Data API into a PHP application using a combination of SimpleXMLand the Zend client library. The examples in this article:

• Introduced you to the two main Google Base feeds

• Explained how Google Base classifies data using item types andattributes

• Showed you how to retrieve Google Base content using a variety ofdifferent filters

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 27 of 30

Page 28: Search and update Google Base with PHP

• Illustrated how to programmatically add, modify and delete content

• Built a customized interface to a user's Google Base data

As these examples illustrate, the Google Base Data API is a powerful and flexibletool for developers ready to build creative new applications around contentaggregation and search. Play with it, and see what you think!

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 28 of 30 © Copyright IBM Corporation 2010. All rights reserved.

Page 29: Search and update Google Base with PHP

Resources

Learn

• The Developer's Guide and Reference Guide: Learn more about the GoogleBase Data API.

• Google Data API authentication: Learn more about the two types.

• The Google Base blog: Track Google Base news.

• Google Account: Register for your own account and get started.

• Google Base API Developer's Forum: Read and join discussions about GoogleBase API development.

• The Zend_Gdata_Gbase library: Read more about the Zend Framework andhow to use it with the Google Base Data API.

• More articles by this author (Vikram Vaswani, developerWorks, August2007-current): Read articles about XML, additional Google APIs and othertechnologies.

• XML area on developerWorks: Get the resources you need to advance yourskills in the XML arena.

• IBM XML certification: Find out how you can become an IBM-CertifiedDeveloper in XML and related technologies.

• XML technical library: See the developerWorks XML Zone for a wide range oftechnical articles and tips, tutorials, standards, and IBM Redbooks.

• developerWorks technical events and webcasts: Stay current with technology inthese sessions.

• developerWorks podcasts: Listen to interesting interviews and discussions forsoftware developers.

Get products and technologies

• The Zend Gdata Client Library Download and get everything you need toaccess Google Base Data APIs.

• IBM product evaluation versions: Download or explore the online trials in theIBM SOA Sandbox and get your hands on application development tools andmiddleware products from DB2®, Lotus®, Rational®, Tivoli®, andWebSphere®.

Discuss

• XML zone discussion forums: Participate in any of several XML-relateddiscussions.

ibm.com/developerWorks developerWorks®

Search and update Google Base with PHP© Copyright IBM Corporation 2010. All rights reserved. Page 29 of 30

Page 30: Search and update Google Base with PHP

• developerWorks blogs: Check out these blogs and get involved.

About the author

Vikram VaswaniVikram Vaswani is the founder and CEO of Melonfire, a consulting services firm withspecial expertise in open-source tools and technologies. He is also the author of thebooks PHP Programming Solutions and PHP: A Beginners Guide.

Trademarks

IBM, the IBM logo, ibm.com, DB2, developerWorks, Lotus, Rational, Tivoli, andWebSphere are trademarks or registered trademarks of International BusinessMachines Corporation in the United States, other countries, or both. These and otherIBM trademarked terms are marked on their first occurrence in this information withthe appropriate symbol (® or ™), indicating US registered or common lawtrademarks owned by IBM at the time this information was published. Suchtrademarks may also be registered or common law trademarks in other countries.See the current list of IBM trademarks.Adobe, the Adobe logo, PostScript, and the PostScript logo are either registeredtrademarks or trademarks of Adobe Systems Incorporated in the United States,and/or other countries.Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in theUnited States, other countries, or both.Other company, product, or service names may be trademarks or service marks ofothers.

developerWorks® ibm.com/developerWorks

Search and update Google Base with PHPPage 30 of 30 © Copyright IBM Corporation 2010. All rights reserved.