[PHP-SOURCE] Amazon Search Engine Script

Discussion in 'PHP' started by Vick.Kumar, Feb 22, 2013.

  1. #1
    Hi,

    I want to contribute to the DP community, so here's a Amazon Search Script. Which let's the user enter what they're searching for, and uses your affiliate store id to retrieve results.

    This is a simple google-like script so you could purchase traffic to the search script and get hits, and for every person who uses your search engine they'll be retrieving items from amazon using your store/affiliate id so if they purchase goods, you earn commission.

    <?php
    error_reporting(0);
    /**
    *  amazonSearch Script
    * 
    *  @author Vick Kumar <vickkumar2011@gmail.com>
    *  @version 1.0
    *  @copyright 2013 © All Rights Reserved
    *  @license http://creativecommons.org/licenses/by-sa/3.0/
    **/
     
    # Steps
    # 1. User enters search query
    # 2. Script searches Amazon
    # 3. Script returns Amazon Results
     
    #usage amazsonSearch("Search Query Here");
    function amazonSearch($q, $affiliateid)
    {
      $url = "http://astore.amazon.com/$affiliateid/search?node=1&keywords=$q&x=13&y=14&preview=";
      $curl = curl_init();
      curl_setopt($curl, CURLOPT_URL, $url);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($curl, CURLOPT_HEADER, 0);
      $result = curl_exec($curl);
      curl_close($curl);
      return print_r($result);
    }
     
    $query = $_POST['q'];
     
      amazonSearch($query, "vickkumar-20");
     
     
    ?>
    <html>
      <head>
        <title>amazonSearch Script</title>
      </head>
     
      <body>
      <form method="post" action="amazonSearch.php">
      Enter search query: <input type="text" size="100" name="q" /><input type="submit" value="Search" />
      </form>
      </body>
    </html>
    PHP:

     
    Vick.Kumar, Feb 22, 2013 IP