Adding an eBay RSS Feed to Your WordPress Blog

Recently I’ve been trying to figure out a way to aggregate eBay auctions for use in one of my real estate websites.  I wanted to do this for two reasons, one being to generate fresh content and the other for trying to inject my Commission Junction affiliate code into the listings. 

The solution came from incorporating two already really popular tools, lastRSS and Exec-PHP.  However I was hitting brick walls getting this stuff to work together.  Finally my buddy Julien pointed me in the right direction.  His example sites using eBay RSS and CJ were just incredible, and the implementation of the scripts was simple…after going through about 10 back and fourth emails.  So to make this an easy task for you, I’ve compiled the process of what I learned from Julien’s blog post and from our emails.

Since the main purpose of this is to generate some cash using the eBay RSS feed and CJ, you need to first go grab your CJ account (that is if you don’t already have one).  After then then you can continue :)

  1. Log into you Commission Junction account and point to Account/Website Settings and then select the website you wish to tie this venture to.  After selecting from the drop down, write down (or past this to notepad) the PID number.  You’ll need this in order to tie your account to the eBay RSS feed.
  2. Download the Exec-PHP plugin for WordPress here and then Activate it in your WordPress administration panel.  Exec-PHP allows you to enter PHP code within your blog postings.  This is necessary in order to pull in the eBay RSS feed into your blog.
  3. Click Users in your WordPress admin screen and scroll to the bottom to Personal Options and un-check the Use the visual rich editor when editing.  I’ve personally only been able to successfully enter PHP code within the postings when turning off the rich editor. 
  4. Go to the eBay advanced search page in order to get your customized RSS feed.
  5. Enter what stuff you would like to pull back from the eBay RSS feed to use on your blog.
  6. Enter in the PID number that you copied from step 1.
  7. Click the search button to generate the desired eBay RSS feed.  Scroll down to bottom of the results page and look for the RSS button.  Right-click and copy the Link Location of the button.  Paste this HUGE URL into notepad for later use.
  8. Download LastRSS and unzip it.  Upload lastRSS.php to your blogs root directory on your server. Create a folder called cache and make it readable and writeable (chmod 777).
  9. Create a new page or posting in WordPress and title it anything you’d like.  For the actual post, enter the following code (keeping in mind that the BIG RED BOLD TEXT that reads ENTER THAT BIG eBAY RSS URL should be replaced with the URL you had already copied to your notepad):

    <?php
    include_once './lastRSS.php';
    $rss = new lastRSS;
    $rss->cache_dir = './cache'; $rss->cache_time = 3600; // one hour
    if ($rs = $rss->get('ENTER THAT BIG eBAY RSS URL'))
    {
    foreach ($rs['items'] as $item) {
    $rsscount++; if ($rsscount< 6) {
    $myvar = $item[description];
    $title = $item[title];
    echo "<b>$title</b>$myvar"
    }}
    if ($rs['items_count'] <= 0) { echo "Sorry, no items found.<br /><br />" } } else { die ('Error: RSS file not found...'); }
    ?>

  10. Go ahead and post the article and you should see the results.  *note: Some webhosting places have fopen(); turned off for “security” reasons.  If this condition exists for you then chances are this thing will not work for you.

There you go.  I’ve set up this on a few of my sites:

If you have any questions please feel free to contact me, either through comments or the contact page. 

As a warning, for the sake of keeping content genuine, this technique should not be used to replace humanly authored content.  Doing so would indeed reduce the quality of “blogtent” on the Internet…which is the last thing we need these days.

12 thoughts on “Adding an eBay RSS Feed to Your WordPress Blog”

  1. Very cool that you put this tutorial up. I tried it out and got it working pretty quick. But then something weird happened. The next day it stopped working. And I can’t figure out why. It seems the lastRSS parser is now not stripping out the CDATA tags and I don’t know why. Any idea if something change somewhere?

  2. Never mind. I found the problem. Operator error of course. While I was tweaking things around I changed the CDATA variable back to ‘nochange’ so it wasn’t stripping the tag off. Working now.

    Thanks again for this post. Very useful.

  3. Trying to run this on my local server and i get a syntax error. C:\wamp\www\wordpress\wp-content\plugins\exec-php\includes\runtime.php(41) : eval()’d code on line 2

    Am i missing something obvious? I’m definitely not a coder but i’m pretty sure i’ve followed your directions correctly.

  4. I get an error:

    Parse error: syntax error, unexpected ‘/’ in /home/clickarc/public_html/wp-content/plugins/exec-php/includes/runtime.php(41) : eval()’d code on line 2

  5. I don’t know hardly a thing about PHP (backyard-hack Perl coder only), but there are a couple of errors in the supplied code… and I got it to work. Here’s what I have:

    cache_dir = ‘./cache’; $rss->cache_time = 3600; // one hour
    if ($rs = $rss->get(‘THIS IS YOUR RSS CODE’))
    {
    foreach ($rs[‘items’] as $item) {
    $rsscount++;
    if ($rsscount< 6) {
    $myvar = $item[description];
    $title = $item[title];
    echo “$title$myvar”;
    }
    }
    }
    ?>

    It was missing a } at the end and a semi-colon on the echo statement.

    You’ll also have to play around with it to get it to display like you want it to… but as of today (Feb 2009), this still works.

Leave a Reply

Your email address will not be published. Required fields are marked *