BSD license FREE

The BSD license is an
open-source license.
Read full license

You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

(2 ratings)

Amazon Product Advertising API PHP Wrapper

  • Developed by Hiraq, Released Mar 26, 2012

PHP library class for amazon product advertising API.

Share and win up to $15k in prizes each month!Learn more

Share

Description

A PHP library class to working with Amazon Product Advertising API, for working with the latest version of Amazon Product Advertising API (2011-08-01).

Requirements :

  • PHP 5.3 (min!)
  • SimpleXMLElement must exist (PHP must be compiled with libxml. It is the default on most configurations)

Features :

  • Search Operation
  • ItemLookup Operation
Back to top

About

I have created this library to helping people working with Amazon Product Advertising API. Using PHP 5.3 version and latest PHP features such as namespace and lambda function, and also latest Amazon Product Advertising API.

For now, this library only supports two main operations :

  1. Search operation
  2. ItemLookup operation
Back to top

Installation

Installation

Copy the library into your working folder, and set library folder into your php include_path settings.

Examples :

  • Working folder : /var/www/amazon/
  • Library copied into /var/www/amazon/php-amazon-pa-wrapper/
  • In your PHP project, use set_include_path to add the library foldor to the include path: set_include_path(get_include_path() . PATH_SEPARATOR.YOUR_ROOT.YOUR_DS . 'php-amazon-pa-wrapper')
  • Call the main class at Amazon.php and setup autoload (to load all the dependencies)

complete code : https://gist.github.com/2177610

Back to top

How To Use

How To Use

This library only support two common amazon product advertising API process :

  • Search
  • ItemLookup

Search request code example :

<?php
/*
 * set operations
 */
 $amazon->request()->search('php');
 $amazon->request()->setParams(array(  
     'SearchIndex' => 'Books',          
     'ResponseGroup' => 'Large'
 ));

 //get response data from sended request
 $amazon->response()->proceed($amazon->request()->send());

 //debug function is my custom function to 'print_r' any variables, you can use your own function.
 //getItems will return all items data from amazon response
 debug($amazon->response()->getItems());

To use Search operation, please do not forget to include 'SearchIndex' when you use setParams.

ItemLookup example:

<?php

/*
 * set operations
 */
 $amazon->request()->detail('0596157134');
 $amazon->request()->setParams(array(            
      'ResponseGroup' => 'Large'
  ));

  $amazon->response()->proceed($amazon->request()->send());
  debug($amazon->response()->getItems());

Response data :

  • to get total results : use method getTotalResults (from Response class)
  • to get total pages : use method getTotalPages (from Response class)
  • to get raw xml data from amazon response : use method getRawXml (from Response class)
  • For any response data you can check in my Response class.
Read all 2 comments »

Questions & Comments

Leave a comment

You must be logged-in to leave a comment.
Log-in now or register for a free account.
You must be logged-in to vote. Log-in to your account or register now.
View all 2 reviews »

User Reviews