Skip to content

Commit 6f139b0

Browse files
committed
Merge pull request #12 from Peardian/throttle
Added: throttle stopper setting & raw report return
2 parents b31ac9c + a81c0ec commit 6f139b0

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

includes/classes/AmazonCore.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ abstract class AmazonCore{
8080
protected $throttleTime;
8181
protected $throttleSafe;
8282
protected $throttleGroup;
83+
protected $throttleStop = false;
8384
protected $storeName;
8485
protected $options;
8586
protected $config;
@@ -403,6 +404,17 @@ public function setStore($s){
403404
}
404405
}
405406

407+
/**
408+
* Enables or disables the throttle stop.
409+
*
410+
* When the throttle stop is enabled, throttled requests will not be repeated.
411+
* This setting is off by default.
412+
* @param boolean $b <p>Defaults to <b>TRUE</b>.</p>
413+
*/
414+
public function setThrottleStop($b=true) {
415+
$this->throttleStop=!empty($b);
416+
}
417+
406418
/**
407419
* Writes a message to the log.
408420
*
@@ -550,7 +562,7 @@ protected function sendRequest($url,$param){
550562
$this->log("Making request to Amazon: ".$this->options['Action']);
551563
$response = $this->fetchURL($url,$param);
552564

553-
while ($response['code'] == '503'){
565+
while ($response['code'] == '503' && $this->throttleStop==false){
554566
$this->sleep();
555567
$response = $this->fetchURL($url,$param);
556568
}

includes/classes/AmazonFeedResult.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* This Amazon Feeds Core object can retrieve the results of a
66
* processed feed from Amazon, which can then be saved to a file
7-
* specified by the user. In order to fetch feed results, the
8-
* feed's ID must be given.
7+
* specified by the user or retrieved as a single string.
8+
* In order to fetch feed results, the feed's ID must be given.
99
*/
1010
class AmazonFeedResult extends AmazonFeedsCore{
1111
private $rawFeed;
@@ -114,5 +114,18 @@ public function saveFeed($path){
114114
}
115115
}
116116

117+
/**
118+
* Returns the entire raw report data.
119+
*
120+
* This is useful for handling the report with an external file management system.
121+
* @return string|boolean The raw report data as a string, or <b>FALSE</b> if there is no data
122+
*/
123+
public function getRawFeed() {
124+
if (!isset($this->rawFeed)){
125+
return false;
126+
}
127+
return $this->rawFeed;
128+
}
129+
117130
}
118131
?>

0 commit comments

Comments
 (0)