Monday, May 22, 2006

Phing, Zend_Search_Lucene, XML_Feed_Writer and OpenSearch

This weekend just past I've been a busy beaver. I've implemented a very basic OpenSearch 1.1 publishing kit: You get results from a search engine, like Zend_Search_Lucene, and add them to an Atom feed.

It's still half full of static urls and completely unusable; but as a proof of concept...

Long story short:

$link = '';

$result = new OpenSearchResponse('search key words');
$result->addItem(new OpenSearchResponseItem('Example A', $link, 'Content goes here!'));
$result->addItem(new OpenSearchResponseItem('Example B', $link, 'Content goes here!'));

print $result->toXML();

... is about as much effort as it takes to create a new feed.

And describing it:

$options = array();
$options["ShortName"] = "Valex";
$options["LongName"] = "Valuation Exchange";
$options["Description"] = "Residential Valuations";
$options["Contact"] = "";
$options["Url"]["atom"] = "{searchTerms}&xml=true";
$options["Url"]["html"] = "{searchTerms}";

header('content-type: text/xml');
$osd = new OpenSearchDescription($options);
print $osd->toXML();

XML_Feed_Writer - You'll have to fix a few, really minor bugs with this.
Zend Framework - You'll need to grab Zend_Search_Lucene, perhaps, or find your own search engine.

Hopefully, I'll get off my ass and rerelease Services_Upcoming, Services_ABR, etc through the work package server, should Robby ever set it up.
Post a Comment