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 = 'http://www.wherever.com/';

$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"] = "daniel.oconnor@megawhogg.com.au";
$options["Url"]["atom"] = "http://ws.valex.com.au/opensearch/1.1/?searchTerms={searchTerms}&xml=true";
$options["Url"]["html"] = "http://vx.valex.com.au/opensearch/1.1/?searchTerms={searchTerms}";

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


Simple!
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.
Finally:
OpenSearch-0.0.1.tgz.

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.

3 comments:

Michael Fagan said...

Have you seen http://lucene-ws.sourceforge.net/ ?

Dan said...

Only very, very briefly, and I never looked into it (seeing as we're primarily a PHP shop).

David said...

Awesome I didn't know you had used my package :). Can you give me a quick shout about the bugs that you had to fix for XML_Feed_Writer ?

Thanks,