Skip to content

Version 1.3 Release Candidate #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 112 commits into from
Aug 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
b64ce7b
Fixed report sales channel param being sent wrong
Peardian May 11, 2015
f1735a3
Adding basic Travis file
Peardian Mar 11, 2016
3e7aa82
Added phpunit config file
Peardian Mar 11, 2016
c65e509
Updated setup tests to use test config
Peardian Mar 11, 2016
0a29d8b
Add Travis badge to readme
Peardian Mar 11, 2016
a4eb547
Merge pull request #68 from Peardian/travis
Peardian Mar 14, 2016
a0627ee
Merge branch 'master' into reportfix
Peardian Mar 14, 2016
0c1236a
Updated report request test with fixed param name
Peardian Mar 14, 2016
14ce98d
Merge pull request #43 from Peardian/reportfix
Peardian Mar 14, 2016
c01b3ec
Added credits and changelog
Peardian Mar 14, 2016
10a9c6e
Added contribution guide
Peardian Mar 14, 2016
95df1b8
Merge pull request #69 from Peardian/credits
carl689 Mar 15, 2016
79bd297
Added support for MWSAuthToken
Peardian Mar 14, 2016
4a93c05
Updated list of supported feeds
Peardian Mar 15, 2016
b92b8cb
Updated feed list with new date fields
Peardian Mar 15, 2016
2ccd546
Updated list of supported reports
Peardian Mar 15, 2016
6950ffc
Updated completedDate in report request list
Peardian Mar 15, 2016
ad8f3f8
Added AcknowledgedDate to report list
Peardian Mar 15, 2016
20f1b30
Added new return fields to order info
Peardian Mar 15, 2016
031a796
Added new parameters for getting order list
Peardian Mar 15, 2016
0e44f89
Added new return elements for order items
Peardian Mar 15, 2016
6e39c78
Removed old extra mock files
Peardian Mar 15, 2016
22db4ea
Updated service URL to work without end slash
Peardian Mar 15, 2016
b47c891
Fixed an unused line in the Amazon URL encode function
Peardian Mar 15, 2016
59d2c47
Changed all private methods and variables to protected
Peardian Mar 15, 2016
f020318
Added method to get raw report data
Peardian Mar 15, 2016
9c23bee
Added: SubscriptionsCore, SubscriptionsDestinationList
linspb Mar 16, 2016
19fa1f8
Added Merchant Fulfillment Core
Peardian Mar 17, 2016
5f3c1d2
Added Merchant Fulfillment Tests
Peardian Mar 21, 2016
2127fda
Added more Merchant Fulfillment Tests
Peardian Mar 21, 2016
aecaacd
Fixed mistakes in documentation
Peardian Mar 22, 2016
ed49fcd
Fixed some documentation in Merchant classes
Peardian Mar 22, 2016
f60ac04
Fixed check in report list
Peardian Mar 23, 2016
10c8b71
Merge pull request #70 from Peardian/updates
Peardian Mar 23, 2016
9b4ace9
Updated merchant docs to clarify currency code
Peardian Mar 23, 2016
e3a25a6
Merge pull request #72 from Peardian/merchant
Peardian Mar 23, 2016
6ed2694
Fixed parameter checks in merchant shipment creator
Peardian Mar 25, 2016
9155411
Corrected some docs in Merchant classes
Peardian Mar 28, 2016
a83703f
Added automatic label file decoding to merchant shipment
Peardian Mar 29, 2016
b62c861
Added new ShipDate option to Merchant Shipment
Peardian Apr 5, 2016
0900a98
Merge pull request #73 from Peardian/fixes
Peardian Apr 13, 2016
a68ce27
Fixed documentation for order getIsPrime
Peardian Apr 15, 2016
753b157
Fixed shipment service level field name in order
Peardian Apr 15, 2016
91afce8
Added core methods for quick access to response codes
Peardian May 16, 2016
4661165
Fixed province typo in Inbound and Outbound classes
Peardian May 16, 2016
6b2410a
Removed old test code from inbound shipment test
Peardian May 16, 2016
bb6caab
Updated composer json to allow newer PHP versions
Peardian May 16, 2016
b2c94e3
Added unix timestamp support to genTime
Peardian May 16, 2016
1980549
Fixed array for product relationships and sales categories
Peardian May 17, 2016
913d1f0
Added method to product classes for changing marketplace option
Peardian May 17, 2016
df0cd91
Added new lowest priced offer action to ProductInfo
Peardian May 17, 2016
fb734e3
Added test for newest product info action
Peardian May 17, 2016
cf4c6ab
Added new options and returns to fulfillment preview class
Peardian May 17, 2016
d5c3a64
Added new action and options to fulfillment order creator
Peardian May 18, 2016
266ab44
Removed deprecated option from fulfillment order creator
Peardian May 18, 2016
7d49b87
Added new fields to fulfillment order info and list
Peardian May 19, 2016
f4205f2
Added new options and fields to inbound shipment planner
Peardian May 19, 2016
29c5408
Updated inbound shipment creator
Peardian May 19, 2016
37d330d
Updated shipment list and shipment item list
Peardian May 19, 2016
87bddf6
Merge pull request #71 from Peardian/privacy
Peardian May 23, 2016
eace24d
Merge pull request #75 from Peardian/fixes
Peardian May 23, 2016
d3294b7
Merge pull request #77 from Peardian/features
Peardian May 23, 2016
814a437
Added new inbound item prep info class
Peardian May 20, 2016
08fe5af
Added test for item prep info class
Peardian May 20, 2016
44a8a73
Added inbound preorder class
Peardian May 23, 2016
1190071
Added tests for inbound preorder class
Peardian May 23, 2016
59d0ad4
Added inbound transport class
Peardian May 23, 2016
5f436ed
Added more actions to the inbound transport class
Peardian May 23, 2016
36ffa57
Fixed inbound preorder setup test
Peardian May 23, 2016
0d44ece
Added get methods to inbound transport class
Peardian May 24, 2016
52e00f6
Added inbound transport document class
Peardian May 24, 2016
8b0ac9e
Added tests for inbound transport document class
Peardian May 24, 2016
ebc4f6f
Added tests for inbound transport class
Peardian May 24, 2016
83b2307
Added more tests for new inbound transport class
Peardian May 25, 2016
2d12c77
SimpleXMLObject to SimpleXMLElement in phpdoc.
May 25, 2016
ddf0ffe
Added order ID to order item list class
Peardian May 25, 2016
1340bca
Merge pull request #81 from dvaqueiro/master
Peardian May 25, 2016
3aa8b55
Updated phpdoc for product lowest price method
Peardian May 25, 2016
968397f
Updated token method to check for MoreResultsAvailable
Peardian May 25, 2016
af6bba2
Fixed xml parse in outbound order class
Peardian May 25, 2016
7bb606c
Fixed product lowest price offer param
Peardian May 25, 2016
6be162a
Added request identifier to product list
Peardian May 26, 2016
6fadc1f
Merge branch 'subscriptions' of dmitriyk/phpAmazonMWS into newapi
Peardian May 26, 2016
acf8daf
Renamed subscription classes
Peardian May 26, 2016
a3b6289
Reorganized and tidied subscription classes
Peardian May 26, 2016
11e7169
Updated phpdoc for new inbound classes
Peardian May 27, 2016
6399226
Added subscription and destination class
Peardian May 27, 2016
853d1a6
Added subscription list class
Peardian May 27, 2016
000e6ce
Added tests for subscription classes
Peardian May 27, 2016
c2ff469
Added Recommendations API classes
Peardian May 31, 2016
9fb7d46
Added tests for recommendations class
Peardian May 31, 2016
b5cd582
Updated phpdocs and old method outbound classes
Peardian Jun 1, 2016
23cb00e
Added item release date to inbound shipment creator
Peardian Jun 1, 2016
369cf38
Fixed phpdocs in the transport classes
Peardian Jun 1, 2016
2d33444
Merge pull request #78 from Peardian/updates
Peardian Jun 1, 2016
ee542ff
Merge pull request #80 from Peardian/inbound
Peardian Jun 1, 2016
bc107db
Merge pull request #82 from Peardian/token
Peardian Jun 1, 2016
48005a4
Merge pull request #83 from Peardian/items
Peardian Jun 1, 2016
f1578a9
Updated phpdocs for subscriptions and recommendations
Peardian Jun 9, 2016
ec1ceaa
Merge pull request #84 from Peardian/newapi
Peardian Jun 9, 2016
abb5be4
Fixes found while adding tests
Peardian Jun 10, 2016
40bc316
Added tests for recently added features
Peardian Jun 10, 2016
eb33a59
Added Finance API classes
Peardian Jun 10, 2016
31f71b4
Added get methods to financial group class
Peardian Jun 13, 2016
ab5745b
Fixed financial event class with actual element names
Peardian Jun 13, 2016
803c73d
Added tests for the new finance classes
Peardian Jun 13, 2016
59c6470
Fixed fulfillment order creator update requirements
Peardian Jun 14, 2016
e0a92c0
Fixed token loop when XML is empty
Peardian Jun 14, 2016
6ac892f
Merge pull request #87 from Peardian/newtests
Peardian Jul 5, 2016
0433750
Merge pull request #89 from Peardian/finance
Peardian Jul 5, 2016
ec60648
Updated change log with upcoming 1.3.0
Peardian Jul 5, 2016
9786c28
Added release date for version 1.3
Peardian Aug 3, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7'
script: cd test-cases && phpunit --bootstrap bootstrap.php
102 changes: 102 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 1.3.0 - 2016-08-03
### Added
- Travis support
- PHPUnit XML configuration file
- Change log file
- Contribution guidelines file
- Credits file
- Added support for MWS Auth Token, which can be set for each store in the config file.
- Added methods for getting the last response code, error message, and error response.
- Added support for the Merchant Fulfillment API with three new classes.
- Added support for the Recommendations API with one new class.
- Added support for the Subscriptions API with three new classes.
- Added support for the Finance API two new classes.
- Added four new Inbound classes relating to preorders, transport, and item prep instructions.
- The marketplace can now be specified in the Order List class, Fulfillment Order class, and all Product classes.
- New response fields in the Feed class: `StartedProcessingDate` and `CompletedProcessingDate`
- New response fields in the Order class: `IsBusinessOrder`, `PurchaseOrderNumber`, `IsPrime`, and `IsPremiumOrder`
- New response fields in the Order Item List class: `BuyerCustomizedInfo`, `PointsGranted`, and `PriceDesignation`
- Added a method for getting the order ID from the Order Item List class.
- New parameter in the Order List class: `TFMShipmentStatus`
- Added a method for getting the raw report data from the Report class.
- New response field in the Report List class: `AcknowledgedDate`
- New response fields in the Fulfillment Order class: `MarketplaceId`, `DeliveryWindow`, `FulfillmentAction`, `CODSettings`, `PerUnitPrice`, and `PerUnitTax`.
- New parameters in the Fulfillment Order Creator class: `MarketplaceId`, `FulfillmentAction`, `CODSettings`, and `DeliveryWindow`. The method for setting items now also has `PerUnitPrice` and `PerUnitTax`.
- New method in the Fulfillment Order Creator class for updating orders.
- New response fields in the Fulfillment Order List class: `MarketplaceId`, `DeliveryWindow`, `FulfillmentAction`, and `CODSettings`.
- New options in the Fulfillment Preview class: `IncludeCODFulfillmentPreview` and `IncludeDeliveryWindows`.
- New response fields in the Fulfillment Preview class: `ShippingSpeedCategory`, `IsFulfillable`, `IsCODCapable`, `MarketplaceId`, and `ScheduledDeliveryInfo`.
- New method in the Product Info class for getting lowest-priced offers.
- The Product class now keeps the identifier used to search for an item under the key `Request`.
- New methods in the Shipment class for setting parameters previously restricted to use of `usePlan`.
- New parameter in the Shipment class: `ShipmentName`. The method for setting items now also supports `PrepDetailsList` and `ReleaseDate` for each item.
- New response fields in the Shipment Item List class: `PrepDetailsList` and `ReleaseDate`
- New response field in the Shipment List class: `ConfirmedNeedByDate`
- New parameters in the Shipment Planner class: `ShipToCountryCode` and `ShipToCountrySubdivisionCode`. The method for setting items now also supports `ASIN` and `PrepDetailsList` for each item.
- New response field in the Shipment Planner class: `PrepDetailsList`
- Added support for new styles of token responses used by some classes.

### Changed
- Some tests that tried to load the normal configuration file now properly load test configuration.
- Corrected many small mistakes in documentation.
- The `setShowSalesChannel` method in the Report class now properly sets the parameter.
- The Service URL setting now works with or without a slash at the end.
- Changed all private methods and properties to protected.
- Updated the Composer file to allow for newer PHP versions.
- Fixed the spelling of `StateOrProvinceCode` throughout the Outbound and Inbound classes.
- The `genTime` method now supports Unix timestamps, though some methods that use `genTime` still do not.
- Updated the name of the `CompletedProcessingDate` field in the Report Request List class to `CompletedDate`.
- Deprecated `getDateProcessingCompleted` in favor of `getDateCompleted`.
- Updated the name of the `ShipServiceLevelCategory` field in the Order class to `ShipmentServiceLevelCategory`.
- Deprecated `getShipServiceLevelCategory` in favor of `getShipmentServiceLevelCategory`.
- Deprecated `setFulfillmentMethod` in the Fulfillment Order Creator class.
- Deprecated `setMethodFilter` in the Fulfillment Order List class.
- The Product Info class now properly gets all relationships.
- The Shipment class no longer sets the address when using `usePlan` and correctly sets other parameters.
- Fixed a loop caused by an empty response to actions that use tokens.

### Removed
- Removed all of the old leftover test XML files from the mock folder
- Removed old environment config lines from the test config file

## 1.2.0 - 2016-03-10
### Added
- The store name can now be omitted when initiating objects if there is only one store is set in the config file.
- Added support for four relatively-new fields returned for Orders: `CbaDisplayableShippingLabel`, `ShippedByAmazonTFM`, `TFMShipmentStatus`, and `OrderType`.
- Each store in the config file can have its own `serviceUrl`, which will override the normal service URL.

### Changed
- Log messages now display time using the 24 hour format, rather than 12 hour.

### Fixed
- Inventory lists no longer cause an error if detailed information is not given.
- Logging function no longer gives an error when PHP is in strict mode.
- Removed bad include paths from NetBeans project settings.
- Product class no longer gives an error when PHP is in strict mode.
- Product Info class now uses the correct identifier parameters when fetching categories.
- Product Info class now correctly gets child relationship data.

### Removed
- Removed the obsolete `checkResponse` method from the Feed class.

## 1.1.0 - 2014-05-06
### Added
- Raw responses are stored for debugging purposes and can be accessed with getLastResponse() or getRawResponses()
- Created a folder for example scripts and added some examples to the readme
- Updated the Orders API to the 2013-09-01 version, which adds Earliest/Latest Ship Date and Delivery Date to returned order data

### Changed
- Feeds now allow for direct string input rather than relying entirely on files
- Amazon-defined constants, such as API version numbers and throttle times, have been moved to a separate file since users shouldn't have to worry about them. Users who already have a config file should redo them.

### Fixed
- HTTP 100 Continue responses are properly handled

## 1.0.0 - 2014-02-12
### Added
- Core class
- Classes for eight APIs: Feeds, Fulfillment Inbound, Fulfillment Inventory, Fulfillment Outbound, Orders, Products, Reports, and Sellers
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Contributing
##General
All pull requests should target the master branch. Commits should not have different code changes mixed together and should have descriptive messages.

##Project Scope
The goal of this project is to provide a library with which the average merchant can communicate with Amazon's MWS services without needing to learn the complex language of the API. When contributing, think about whether or not the contribution is something that the average Amazon merchant would need to intract with Amazon.

Code for handling the merchant's data, such as for generating feeds or data crunching, falls outside of the library's intended scope and, while useful, is best left to separate projects.

##Code Guidelines
The library is written using a custom style and does not follow any particular standard. For the sake of cohesion, changes to the code should be written in this same style. Please do not make changes to the style of the code.

Any new changes should fit within the previously-mentioned goal of the project. New public methods and classes should have names that are easy to understand and use without needing to consult the API's documentation. Try to follow the trend of similar existing functions, such as how methods that send requests to get information from Amazon usually have names that start with "fetch."

New methods should have phpdocs explaining how to use them and how they will affect the options sent in the next request. New classes should have phpdocs explaining their purpose and the workflow for using them. If the class is one that sends requests to Amazon, the documentation should indicate which Amazon actions it can perform and which of its methods are required before a request can be sent. Check the phpdocs on existing classes for examples.
1 change: 1 addition & 0 deletions CREDITS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The phpAmazonMWS library was designed and written by Thomas Hernandez (peardian at gmail) for the CPI Group.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
phpAmazonMWS
============

[![Build Status](https://travis-ci.org/CPIGroup/phpAmazonMWS.svg?branch=stable)](https://travis-ci.org/CPIGroup/phpAmazonMWS)

A library to connect to Amazon's Merchant Web Services (MWS) in an object-oriented manner, with a focus on intuitive usage.

This is __NOT__ for Amazon Web Services (AWS) - Cloud Computing Services.
Expand Down
1 change: 1 addition & 0 deletions amazon-config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$store['YourAmazonStore']['keyId'] = ''; //Access Key ID
$store['YourAmazonStore']['secretKey'] = ''; //Secret Access Key for this store
$store['YourAmazonStore']['serviceUrl'] = ''; //optional override for Service URL
$store['YourAmazonStore']['MWSAuthToken'] = ''; //token needed for web apps and third-party developers

//Service URL Base
//Current setting is United States
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "Apache-2.0",
"keywords": ["API", "Amazon", "PHP"],
"require":{
"php": "~5.4",
"php": ">=5.4",
"ext-curl": "*"
},
"require-dev": {
Expand Down
18 changes: 17 additions & 1 deletion environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@

//Version numbers for cores
$AMAZON_VERSION_FEEDS = '2009-01-01';
$AMAZON_VERSION_FINANCE = '2015-05-01';
$AMAZON_VERSION_INBOUND = '2010-10-01';
$AMAZON_VERSION_INVENTORY = '2010-10-01';
$AMAZON_VERSION_MERCHANT = '2015-06-01';
$AMAZON_VERSION_ORDERS = '2013-09-01';
$AMAZON_VERSION_OUTBOUND = '2010-10-01';
$AMAZON_VERSION_PRODUCTS = '2011-10-01';
$AMAZON_VERSION_RECOMMEND = '2013-04-01';
$AMAZON_VERSION_REPORTS = '2009-01-01';
$AMAZON_VERSION_SELLERS = '2011-07-01';
$AMAZON_VERSION_SUBSCRIBE = '2013-07-01';

//Amazon Throttle Values in seconds
//Fetching Orders
Expand Down Expand Up @@ -82,11 +86,23 @@
//Submitting a Feed
$THROTTLE_LIMIT_FEEDSUBMIT = 15;
$THROTTLE_TIME_FEEDSUBMIT = 120;
//Getting a Feed
//Fetching a Feed List
$THROTTLE_LIMIT_FEEDLIST = 10;
$THROTTLE_TIME_FEEDLIST = 45;
//Getting a Feed
$THROTTLE_LIMIT_FEEDRESULT = 15;
$THROTTLE_TIME_FEEDRESULT = 60;
//Merchant Fulfillments
$THROTTLE_LIMIT_MERCHANT = 10;
$THROTTLE_TIME_MERCHANT = 1;
//Subscriptions
$THROTTLE_LIMIT_SUBSCRIBE = 25;
$THROTTLE_TIME_SUBSCRIBE = 1;
//Recommendations
$THROTTLE_LIMIT_RECOMMEND = 8;
$THROTTLE_TIME_RECOMMEND = 2;
//Recommendations
$THROTTLE_LIMIT_FINANCE = 30;
$THROTTLE_TIME_FINANCE = 2;

?>
93 changes: 81 additions & 12 deletions includes/classes/AmazonCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ public function setMock($b = true,$files = null){
* including the name and path of the file involved. For retrieving response
* codes, see <i>fetchMockResponse</i>.
* @param boolean $load [optional] <p>Set this to <b>FALSE</b> to prevent the
* method from loading the file's contents into a SimpleXMLObject. This is
* method from loading the file's contents into a SimpleXMLElement. This is
* for when the contents of the file are not in XML format, or if you simply
* want to retrieve the raw string of the file.</p>
* @return SimpleXMLObject|string|boolean <p>A SimpleXMLObject holding the
* @return SimpleXMLElement|string|boolean <p>A SimpleXMLElement holding the
* contents of the file, or a string of said contents if <i>$load</i> is set to
* <b>FALSE</b>. The return will be <b>FALSE</b> if the file cannot be
* fetched for any reason.</p>
Expand Down Expand Up @@ -362,7 +362,7 @@ public function setConfig($path){
$this->config = $path;
$this->setLogPath($logpath);
if (isset($AMAZON_SERVICE_URL)) {
$this->urlbase = $AMAZON_SERVICE_URL;
$this->urlbase = rtrim($AMAZON_SERVICE_URL, '/') . '/';
}
} else {
throw new Exception("Config file does not exist or cannot be read! ($path)");
Expand Down Expand Up @@ -431,6 +431,9 @@ public function setStore($s=null){
if (!empty($store[$s]['serviceUrl'])) {
$this->urlbase = $store[$s]['serviceUrl'];
}
if (!empty($store[$s]['MWSAuthToken'])) {
$this->options['MWSAuthToken'] = $store[$s]['MWSAuthToken'];
}

} else {
$this->log("Store $s does not exist!",'Warning');
Expand Down Expand Up @@ -543,17 +546,22 @@ public function getOptions(){
* The string given is passed through <i>strtotime</i> before being used. The
* value returned is actually two minutes early, to prevent it from tripping up
* Amazon. If no time is given, the current time is used.
* @param string $time [optional] <p>The time to use. Since this value is
* @param string|int $time [optional] <p>The time to use. Since any string values are
* passed through <i>strtotime</i> first, values such as "-1 hour" are fine.
* Unix timestamps are also allowed. Purely numeric values are treated as unix timestamps.
* Defaults to the current time.</p>
* @return string Unix timestamp of the time, minus 2 minutes.
* @throws InvalidArgumentException
*/
protected function genTime($time=false){
if (!$time){
$time = time();
} else {
} else if (is_numeric($time)) {
$time = (int)$time;
} else if (is_string($time)) {
$time = strtotime($time);

} else {
throw new InvalidArgumentException('Invalid time input given');
}
return date('Y-m-d\TH:i:sO',$time-120);

Expand Down Expand Up @@ -646,6 +654,69 @@ public function getRawResponses() {
return false;
}
}

/**
* Gives the response code from the last response.
* This data can also be found in the array given by getLastResponse.
* @return string|int standard REST response code (200, 404, etc.) or <b>NULL</b> if no response
* @see getLastResponse
*/
public function getLastResponseCode() {
$last = $this->getLastResponse();
if (!empty($last['code'])) {
return $last['code'];
}
}

/**
* Gives the last response with an error code.
* This may or may not be the same as the last response if multiple requests were made.
* @return array associative array of HTTP response or <b>NULL</b> if no error response yet
* @see getLastResponse
*/
public function getLastErrorResponse() {
if (!empty($this->rawResponses)) {
foreach (array_reverse($this->rawResponses) as $x) {
if (isset($x['error'])) {
return $x;
}
}
}
}

/**
* Gives the Amazon error code from the last error response.
* The error code uses words rather than numbers. (Ex: "InvalidParameterValue")
* This data can also be found in the XML body given by getLastErrorResponse.
* @return string Amazon error code or <b>NULL</b> if not set yet or no error response yet
* @see getLastErrorResponse
*/
public function getLastErrorCode() {
$last = $this->getLastErrorResponse();
if (!empty($last['body'])) {
$xml = simplexml_load_string($last['body']);
if (isset($xml->Error->Code)) {
return $xml->Error->Code;
}
}
}

/**
* Gives the error message from the last error response.
* Not all error responses will have error messages.
* This data can also be found in the XML body given by getLastErrorResponse.
* @return string Amazon error code or <b>NULL</b> if not set yet or no error response yet
* @see getLastErrorResponse
*/
public function getLastErrorMessage() {
$last = $this->getLastErrorResponse();
if (!empty($last['body'])) {
$xml = simplexml_load_string($last['body']);
if (isset($xml->Error->Message)) {
return $xml->Error->Message;
}
}
}

/**
* Sleeps for the throttle time and records to the log.
Expand All @@ -659,14 +730,11 @@ protected function sleep(){

/**
* Checks for a token and changes the proper options
* @param SimpleXMLObject $xml <p>response data</p>
* @param SimpleXMLElement $xml <p>response data</p>
* @return boolean <b>FALSE</b> if no XML data
*/
protected function checkToken($xml){
if (!$xml){
return false;
}
if ($xml->NextToken){
if ($xml && $xml->NextToken && (string)$xml->HasNext != 'false' && (string)$xml->MoreResultsAvailable != 'false'){
$this->tokenFlag = true;
$this->options['NextToken'] = (string)$xml->NextToken;
} else {
Expand Down Expand Up @@ -768,7 +836,8 @@ function fetchURL ($url, $param) {
*/
protected function _urlencode($value) {
return rawurlencode($value);
return str_replace('%7E', '~', rawurlencode($value));
//Amazon suggests doing this, but it seems to break things rather than fix them:
//return str_replace('%7E', '~', rawurlencode($value));
}

/**
Expand Down
Loading