From 65192c02c206e0abdfb6757ab599ffd4dca07cb5 Mon Sep 17 00:00:00 2001 From: joe-pritchard Date: Thu, 22 Mar 2018 16:59:01 +0000 Subject: [PATCH 1/4] Revert to the original parameter stringify method The way the params were stringified in the original repo is actually preferable, as using your way the created signatures are invalid when your params have spaces or other non-url safe characters in them. I've verified this on the InboundShipments Api methods where I was pushing SKUs containing spaces and forward slashes. With the method like this it works, and with the modified version you either end up double-encoding or you get an invalid signature error and the call fails --- includes/classes/AmazonCore.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/includes/classes/AmazonCore.php b/includes/classes/AmazonCore.php index 705d1035..af0b8148 100644 --- a/includes/classes/AmazonCore.php +++ b/includes/classes/AmazonCore.php @@ -852,14 +852,11 @@ protected function _urlencode($value) { * @return string */ protected function _getParametersAsString(array $parameters) { -// $queryParameters = array(); -// foreach ($parameters as $key => $value) { -// $queryParameters[] = $key . '=' . $this->_urlencode($value); -// } -// return implode('&', $queryParameters); - - // We may as well use the input method! - return http_build_query($parameters); + $queryParameters = array(); + foreach ($parameters as $key => $value) { + $queryParameters[] = $key . '=' . $this->_urlencode($value); + } + return implode('&', $queryParameters); } /** @@ -927,4 +924,4 @@ protected function _sign($data, $key, $algorithm) // -- End Functions from Amazon -- -} \ No newline at end of file +} From 3863136b94685e51120ab826c092e7f632f71a4d Mon Sep 17 00:00:00 2001 From: joe-pritchard Date: Wed, 21 Nov 2018 15:56:50 +0000 Subject: [PATCH 2/4] Update AmazonShipmentItemList.php It's okay for shipmentID not to be set as long as time constraints are set --- includes/classes/AmazonShipmentItemList.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/classes/AmazonShipmentItemList.php b/includes/classes/AmazonShipmentItemList.php index 58f5de37..e7ce7d9a 100644 --- a/includes/classes/AmazonShipmentItemList.php +++ b/includes/classes/AmazonShipmentItemList.php @@ -155,8 +155,10 @@ public function resetTimeLimits(){ * @return boolean FALSE if something goes wrong */ public function fetchItems($r = true){ - if (!array_key_exists('ShipmentId', $this->options)){ - $this->log("Shipment ID must be set before requesting items!",'Warning'); + if (!array_key_exists('ShipmentId', $this->options) + && (!array_key_exists('LastUpdatedAfter', $this->options) && !array_key_exists('LastUpdatedBefore', $this->options)) + ) { + $this->log("Shipment ID or time constraints must be set before requesting items!", 'Warning'); return false; } From fb143e4aa83074e2c74ab88aa01e246b2863bf3a Mon Sep 17 00:00:00 2001 From: Joe Pritchard Date: Wed, 8 May 2019 14:23:16 +0000 Subject: [PATCH 3/4] Content type fix --- includes/classes/AmazonFeed.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/includes/classes/AmazonFeed.php b/includes/classes/AmazonFeed.php index f45e7e68..f514f9de 100644 --- a/includes/classes/AmazonFeed.php +++ b/includes/classes/AmazonFeed.php @@ -28,22 +28,22 @@ class AmazonFeed extends AmazonFeedsCore{ protected $response; protected $feedContent; protected $feedMD5; - + /** * AmazonFeed submits a Feed to Amazon. - * + * * The parameters are passed to the parent constructor, which are * in turn passed to the AmazonCore constructor. See it for more information * on these parameters and common methods. - * @param string $s [optional]

Name for the store you want to use. - * This parameter is optional if only one store is defined in the config file.

* @param boolean $mock [optional]

This is a flag for enabling Mock Mode. * This defaults to FALSE.

* @param array|string $m [optional]

The files (or file) to use in Mock Mode.

* @param string $config [optional]

An alternate config file to set. Used for testing.

+ * @internal param string $s [optional]

Name for the store you want to use. + * This parameter is optional if only one store is defined in the config file.

*/ - public function __construct($s = null, $mock = false, $m = null, $config = null){ - parent::__construct($s, $mock, $m, $config); + public function __construct($mock = false, $m = null, $config = null){ + parent::__construct($m, $config); include($this->env); $this->options['Action'] = 'SubmitFeed'; @@ -293,16 +293,18 @@ protected function parseXML($xml){ $this->log("Successfully submitted feed #".$this->response['FeedSubmissionId'].' ('.$this->response['FeedType'].')'); } - + /** * Generates array for Header. - * + * * This method creates the Header array to use with cURL. It contains the Content MD5. * @return array */ protected function genHeader(){ - $return[0] = "Content-MD5:".$this->feedMD5; - return $return; + return [ + "Content-Type: text/xml", + "Content-MD5:" . $this->feedMD5, + ]; } /** @@ -325,7 +327,15 @@ public function getResponse(){ } } + /** + * + * Returns currently set feed content + * @return mixed + */ + public function getFeedContent(){ + return $this->feedContent; + } } -?> \ No newline at end of file +?> From 955ca665bdb6f3d2e4d9ac613b6e70e935e041be Mon Sep 17 00:00:00 2001 From: Joe Pritchard Date: Wed, 8 May 2019 14:33:24 +0000 Subject: [PATCH 4/4] Add the custom config stuff back in --- includes/classes/AmazonFeed.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/classes/AmazonFeed.php b/includes/classes/AmazonFeed.php index f514f9de..7ebee099 100644 --- a/includes/classes/AmazonFeed.php +++ b/includes/classes/AmazonFeed.php @@ -42,8 +42,8 @@ class AmazonFeed extends AmazonFeedsCore{ * @internal param string $s [optional]

Name for the store you want to use. * This parameter is optional if only one store is defined in the config file.

*/ - public function __construct($mock = false, $m = null, $config = null){ - parent::__construct($m, $config); + public function __construct($s = null, $mock = false, $m = null, $config = null){ + parent::__construct($s, $mock, $m, $config); include($this->env); $this->options['Action'] = 'SubmitFeed';