O'Reilly logo

eBay Hacks, 2nd Edition by David A. Karp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #106. 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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required