diff --git a/.gitignore b/.gitignore index 22d0d82..f6d532e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ vendor +/nbproject/private/ \ No newline at end of file diff --git a/lib/CurlRequest.php b/lib/CurlRequest.php index 950d032..eb59477 100644 --- a/lib/CurlRequest.php +++ b/lib/CurlRequest.php @@ -140,18 +140,24 @@ public static function delete($url, $httpHeaders = array()) */ protected static function processRequest($ch) { - // $output contains the output string - $output = curl_exec($ch); - + # Check for 429 leaky bucket error + while(1) { + $output = curl_exec($ch); + self::$lastHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if(self::$lastHttpCode != 429) { + break; + } + usleep(500000); + } + if (curl_errno($ch)) { throw new Exception\CurlException(curl_errno($ch) . ' : ' . curl_error($ch)); } - self::$lastHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - // close curl resource to free up system resources curl_close($ch); return $output; } + } \ No newline at end of file diff --git a/lib/HttpRequestJson.php b/lib/HttpRequestJson.php index faf5af3..91e80db 100644 --- a/lib/HttpRequestJson.php +++ b/lib/HttpRequestJson.php @@ -68,7 +68,6 @@ public static function get($url, $httpHeaders = array()) { self::prepareRequest($httpHeaders); - ShopifySDK::checkApiCallLimit(); $response = CurlRequest::get($url, self::$httpHeaders); return self::processResponse($response); @@ -87,7 +86,6 @@ public static function post($url, $dataArray, $httpHeaders = array()) { self::prepareRequest($httpHeaders, $dataArray); - ShopifySDK::checkApiCallLimit(); $response = CurlRequest::post($url, self::$postDataJSON, self::$httpHeaders); return self::processResponse($response); @@ -106,7 +104,6 @@ public static function put($url, $dataArray, $httpHeaders = array()) { self::prepareRequest($httpHeaders, $dataArray); - ShopifySDK::checkApiCallLimit(); $response = CurlRequest::put($url, self::$postDataJSON, self::$httpHeaders); return self::processResponse($response); @@ -124,7 +121,6 @@ public static function delete($url, $httpHeaders = array()) { self::prepareRequest($httpHeaders); - ShopifySDK::checkApiCallLimit(); $response = CurlRequest::delete($url, self::$httpHeaders); return self::processResponse($response);