Receive Search Results via RSS

Use PHP to distill eBay search results into a format that can be read by an RSS news aggregator.

RSS is a popular way to track changes to news sites and blogs. When a site adds new content, it updates its RSS feed with information on the new item, including the title, URL, and description.

Using a news aggregator program, you can subscribe to RSS feeds for your favorite sites. These programs watch for changes in RSS feeds. When they find something new, they retrieve the listing and display it to you. This allows you to easily keep up-to-date on hundreds of web sites without needing to continually go back to each site looking for new material.

While RSS is most commonly used to track articles and blog posts, you can also use it to track eBay listings. This hack creates a PHP 5 script that searches eBay and converts the results to RSS using XSLT. This hack reuses many of the components from “Create Custom-Formatted eBay Search Results with the REST API” [Hack #107] , so you may want to read that one before continuing with this one.

RSS readers, however, can’t understand eBay’s XML results, so you need to convert the output into RSS. Conveniently, RSS is also an XML-based format, so it’s easy to use XSLT to turn eBay XML into RSS XML.

Here’s an XSL stylesheet that does that:

 <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" xmlns:ebay="http://ebay.com/api/functions" xmlns:func="http://exslt.org/functions" ...

Get eBay Hacks, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.