/** * _invokePost takes the parameters and invokes the _httpPost function to POST the parameters * exponential retries on error 500 and 503 * The response from the POST is an XML which is converted to Array */ private function _invokePost($parameters) { $response = array(); $statusCode = 200; $this->_success = false; /* Submit the request and read response body */ try { $shouldRetry = true; $retries = 0; do { try { $this->_constructUserAgentHeader(); $httpCurlRequest = new HttpCurl($this->_config); $httpCurlRequest->_httpPost($this->_mwsServiceUrl, $this->_userAgent, $parameters); $response = $httpCurlRequest->getResponse(); //split the API response into Response Body and the other parts of the response into other list($other, $responseBody) = explode("\r\n\r\n", $response, 2); $other = preg_split("/\r\n|\n|\r/", $other); list($protocol, $code, $text) = explode(' ', trim(array_shift($other)), 3); $response = array('Status' => (int) $code, 'ResponseBody' => $responseBody); $statusCode = $response['Status']; if ($statusCode == 200) { $shouldRetry = false; $this->_success = true; } elseif ($statusCode == 500 || $statusCode == 503) { $shouldRetry = true; if ($shouldRetry && strtolower($this->_config['handle_throttle'])) { $this->_pauseOnRetry(++$retries, $statusCode); } } else { $shouldRetry = false; } } catch (Exception $e) { throw $e; } } while ($shouldRetry); } catch (Exception $se) { throw $se; } return $response; }
private function _getCertificate($certificatePath) { $httpCurlRequest = new HttpCurl($this->_ipnConfig); $httpCurlRequest->_httpGet($certificatePath); $response = $httpCurlRequest->getResponse(); return $response; }