CaRP Evolution Documentation
CaRP Evolution Documentation
twitter youtube linkedin google-plus
CaRP Evolution Box
Web This Site

CaRP: Caching RSS Parser - Documentation


CaRP Interactive FAQ
Getting Started: Free Download | Purchase | Install
Reference: Functions | Plugins | Themes | Full Index
Etc.: Display Formatting | Example Code | Affiliates

Amazon.com Associates Example

Amazon.com associates, use this code to easily display best sellers based on whatever search terms you want The results are cached and refreshed every 12 hours, speeding the performance of your website. Once you've finished the main setup, adding custom best seller lists all over your website will be a snap!

UPDATE: Amazon no longer offers search based RSS feeds, so this example no longer works. See the link to Grouper Evolution's affiliate RSS example below for a method that still works (using CaRP Evolution and Grouper Evolution together.)
This example was updated in November 2012 due to the fact that Amazon has dropped support for XSL in their web services API.
For another method of generating affiliates RSS feeds, check out Grouper Evolution. It includes plugins supporting Amazon.com (with much more control over formatting), Shopping.com and All Posters' affiliate programs. [Affiliates RSS Example]

Here's how to use the code on your server:

  1. Download the code and unzip it.
  2. Open "Amazon2RSS-2.0.php" in a text editor like Notepad (not a word processor like Word). If you're not in Windows, you may see funny characters at the beginning or end of every line. If so, either ignore them -- they're not important -- or get a text editor that can handle Windows or DOS style linebreaks.
  3. At the top of Amazon2RSS-2.0.php, enter your Amazon affiliate ID ("Associate Tag"), like this:
    $AssociateTag='moulc';
  4. Upload Amazon2RSS-2.0.php to the CaRP folder on your folder (put them in the same folder as carp.php).
  5. Find an Amazon.com logo you like and upload a copy of it to your website.
  6. Finally, copy the following code (which will be a template for adding Amazon links to your web pages) and save it on your computer, changing:
    • the URL of the image to point to the one uploaded to your site in the previous step.
    • the associates ID in the image link (where it says "tag=moulc") to your ID.
    • the path to where you uploaded Amazon2RSS-2.0.php on your server.
    • If you don't have the "Replace Text" plugin from CaRP Evolution version 4, add the code "$showCustomerTags=1;"
    <div style="width:200;height:420px;overflow:auto;margin:5px;padding:5px;background:#cccccc;">
    <span style="color:#003366;font-size:16pt;font-weight:bold;">Best sellers from</span><br>
    <a href="http://www.amazon.com/exec/obidos/redirect?tag=moulc&path=subst/home/home.html"><img src="http://www.yourwebsite.com/img/126X32-w-logo.gif" border="0"></a><br>
    <?php
    $q='web design';
    $MaxItems=5;
    $amazonSearchType='popular';
    $amazonThreshold=5;
    include '/path/to/Amazon2RSS-2.0.php';
    ?>
    </div>
    

You've completed the main setup. Now you can add Amazon links to any page by pasting a copy of the code saved in the last step above into your web page with the following changes as needed:

  • the styles of the div and span to look the way you want them to (If you don't want everything displayed in a scrolling box, remove the opening and closing div tags completely).
  • the value of $q to the search terms you wish to use.
  • the value of $MaxItems to the maximum number of items you wish to display.
  • the value of $amazonSearchType to "new" or "recent".
  • the value of $amazonThreshold to control how many people must have tagged an item with your search terms for it to be displayed.

If you're displaying ads in a wide space, you'll want to force the images to "float" to make the output look better. To do that, first, add the following code to the "head" section of your webpage (or add the CSS code to your stylesheet):

<style type="text/css">
.floatimgleft img { float:left; margin-right:15px; }
</style>

Then, add class="floatimgleft" to the "div" tag at the start of your Amazon ads, so that it looks something like this (I've also removed the sizing settings from the previous example code):

<div class="floatimgleft" style="margin:5px;padding:5px;background:#cccccc;">

That's it! Something like the examples to the right will appear on your web page.

Best sellers from