Download the PHP package marcl/amazonproductapi without Composer
On this page you can find all versions of the php package marcl/amazonproductapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marcl/amazonproductapi
More information about marcl/amazonproductapi
Files in marcl/amazonproductapi
Package amazonproductapi
Short Description PHP library to perform product lookup and searches using the Amazon Product API.
License MIT
Homepage https://github.com/MarcL/AmazonProductAPI/
Informations about the package amazonproductapi
AmazonProductAPI
PHP library to perform product lookup and searches using the Amazon Product API.
Installation
This library requires the SimpleXML and Curl extensions to be installed and uses PHP 7+ . Installation is simple using Composer:
Amazon Product API
It also assumes that you have some basic knowledge of Amazon's Product API and have set up an Amazon Associate account see: Amazon Product API Set Up.
You'll need an AWS key, secret key, and associate tag. Ensure that you keep these safe!
Examples
I've added some simple examples in examples.php
. To run them create a file called secretKeys.php
containing your secret keys:
and then run the examples with:
Quick Start
Include the library in your code using the Composer autoloader and create an AmazonUrlBuilder with your credentials
Note: Keep your Amazon keys safe. Either use environment variables or include from a file that you don't check into GitHub.
Locale
This library supports all Product Advertising API locales and you can set it as you construct the AmazonUrlBuilder class with your keys.
At this time, these are the current supported locales:
- Brazil ('br')
- Canada ('ca')
- China ('cn')
- France ('fr')
- Germany ('de')
- India ('in')
- Italy ('it')
- Japan ('jp')
- Mexico ('mx')
- Spain ('es')
- United Kingdom ('uk')
- United States ('us')
Item Search
To search for an item use the ItemSearch()
method:
Default sort
By default, the ItemSearch()
method will search by featured. If you want to sort by another category then pass a 3rd parameter with the name of the category you wish to sort by. These differ by category type but the two you'll probably need are price
(sort by price low to high) or -price
(sort by price high to low). See ItemSearch Sort Values for more details.
To determine valid categories for search call GetValidSearchNames()
:
Item Lookup
To look up product using the product ASIN number use ItemLookup()
:
Data Transformation
By default the data will be returned as SimpleXML nodes. However, you can ask for the data to be transformed differently, depending on your use case for the API. Pass a type when instantiating the AmazonAPI class as follows:
This will output:
This will return a simplified version of each item with minimal data but enough for simple use cases.
The different data transformation types are defined as follows. Feel free to raise an issue if you'd like the data transforming to a new type.
- xml - (Default) returns data as SimpleXML nodes.
- array - Returns data as PHP arrays and objects.
- simple - Returns data as simplified arrays and doesn't contain all API data. Use this if you just need prices, title and images.
- json - Returns data as a JSON string. Use this for returning from a server API endpoint.
TODO
- Need to make the simplified data less hardcoded!
Thanks
This library uses code based on AWS API authentication For PHP by David Drake but has been mostly rewritten.
LICENSE
See LICENSE