SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Mar 2009
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting results from Amazon API onto my webpage

    I'm currently in the process of creating a search page which will be using the Amazon catalog for results. All I want to do is search for a title at Amazon and bring back the results onto my webpage. I've signed up to the Product Advertising API and have read the documents they supply but it just doesn't explain a simply, easy to understand way to do it. Does anyone has a tutorial or guide as to how to do this? There are quite a few tutorials on the web but these are either outdated or do not explain what it does. I want to understand what it is the code does rather than just copy and paste it into my website.

    Thanks in advance

  2. #2
    SitePoint Addict
    Join Date
    Mar 2009
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I take it nobody has tried to do this. Thanks anyways

  3. #3
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,255
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)
    Hi freakystreak,

    Don't give up so fast I've used the Amazon product API before to grab images and pricing information, so I might be able to help. What exactly do you want to do? Is the title that you want to search for is only in a specific category (e.g. DVDs)? And what kind of results do you want to display on your site?

  4. #4
    SitePoint Addict
    Join Date
    Mar 2009
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply, I want to search for games, dvds, blurays and music using a search form on my website. I just need to callback the title, artist or director/star and what it is (game, dvd, music cd). The documentation seems very confusing. I just need some example code to get me on the right path or a nudge in the right direction. If you can help in any way it will be greatly appreciated.

  5. #5
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,255
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)
    Here's some code that should get you started. It uses a PHP library called APaPi. Note that I haven't used this code in a while, so it's quite possible Amazon have changed the API since.

    PHP Code:
    require_once( dirname(__FILE__) . '/Amazon/AmazonProductAPI.php' );
    spl_autoload_register(array('AmazonProductAPI''autoload') );

    $api = new AmazonProductAPI();
    $api->setAccessKey'yourAccessKey' );
    $api->setSecretKey'yourSecretKey' );
    $api->setAssociateId'yourAssociateId' );
    $api->setLocale"UK" ); // Set to the Amazon locale you want to search

    $request = new AmazonProduct_Request();
    $request->Operation AmazonProduct_Operation::ITEM_SEARCH;
    // AmazonProduct_SearchIndex::SupportedSearchIndexes() will give you a list of the supported indexes
    $request->SearchIndex AmazonProduct_SearchIndex::VIDEO_GAMES;
    // You may need to change the response group to get the info you need (eg. artist or director)
    $request->ResponseGroup AmazonProduct_ResponseGroup::SMALL;

    // Search by keywords
    $request->Keywords $terms;
    // or title
    $request->Title $terms;

     
    // Send Request
    $response $this->_api->execute$request );

    // verify and use the response
    if( $response->isSuccess() && $response->TotalResults )
    {
        
    // Do something with $response->Items


  6. #6
    SitePoint Addict
    Join Date
    Mar 2009
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks very much for the heads up. Will take a look this week. Really appreciate it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •