1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Freebie: Instant checkout script - Use your OWN landing pages to sell the product

Discussion in 'Amazon' started by DXL, Nov 29, 2006.

  1. #1
    If you were wondering, like me, how to let your visitors buy Amazon products directly, without seeing the product page first, here's the solution.
    Create your own landing page for a certain product and let your visitors go to Amazon checkout directly to purchase it.

    This is what it looks like:
    [​IMG]

    To do this, save the following code as checkout.php and create a link to checkout.php?i=ASIN_HERE.
    <?php
    //Amazon Easy Checkout
    //Copyright (C) 2006 Daniel "DXL" de Leeuw.
    //If you like/use this script, please consider making a donation to danieldl@gmail.com with PayPal.
    
    //Configuration === Edit this!
    $access_key = 'XXXXXXXXXXXXXXXXX';
    $associate_tag = 'XXXXXXXXXXXX-20';
    
    //Basics
    $base_url = 'http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId='.$access_key.'&AssociateTag='.$associate_tag;
    preg_match('/([A-Z0-9]+)/i', $_GET['i'], $matches);
    $asin = $matches[1];
    
    //Cart Creation
    $creation = httpget($base_url.'&Operation=CartCreate&Item.1.ASIN='.$asin.'&Item.1.Quantity=1');
    preg_match('/<PurchaseURL>([^<]+)<\/PurchaseURL>/', $creation, $matches);
    if($matches[1])
        header('Location: '.$matches[1]);
    else
        print 'Sorry, an error occured. Your request could not be fulfilled.';
    
    //Functions
    function httpget($url) {
        return implode("\n", file($url));
    }
    ?>
    PHP:
    If you like this, please give me some green rep or $1 (I'm at PayPal).

    ~DXL

    P.S. Of course feel free to redistribute, providing proper attribution.
     
    DXL, Nov 29, 2006 IP