Example #1
0
 public function send(Request\Request $request)
 {
     if (!$request->isSigned()) {
         $request->sign();
     }
     $curl = curl_init($this->getBaseUrl());
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
     curl_setopt($curl, CURLOPT_HEADER, true);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getDocumentString());
     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=UTF-8'));
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     if ($this->verification === false) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     }
     if ($this->proxyUrl != null) {
         curl_setopt($curl, CURLOPT_PROXY, $this->proxyUrl);
     }
     $response = curl_exec($curl);
     if ($this->proxyUrl != null) {
         // Clear up proxy response:
         if (stripos($response, "HTTP/1.0 200 Connection established\r\n\r\n") !== false) {
             $response = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $response);
         }
         if (stripos($response, "HTTP/1.1 200 Connection established\r\n\r\n") !== false) {
             $response = str_ireplace("HTTP/1.1 200 Connection established\r\n\r\n", '', $response);
         }
     }
     if (stripos($response, "HTTP/1.1 100 Continue\r\n\r\n") !== false) {
         $response = str_ireplace("HTTP/1.1 100 Continue\r\n\r\n", '', $response);
     }
     // Split headers and body:
     list($headers, $body) = explode("\r\n\r\n", $response, 2);
     // Explode headers
     $headers = explode("\r\n", $headers);
     return $this->handleResult($request, $headers, $body);
 }
Example #2
0
 public function send(Request\Request $request)
 {
     if (!$request->isSigned()) {
         $request->sign();
     }
     $curl = curl_init($this->getBaseUrl());
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
     curl_setopt($curl, CURLOPT_HEADER, true);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getDocumentString());
     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type' => 'text/xml; charset=UTF-8'));
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     if ($this->verification === false) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     }
     $response = curl_exec($curl);
     $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
     $headers = explode("\r\n", substr($response, 0, $header_size));
     $body = substr($response, $header_size);
     return $this->handleResult($request, $headers, $body);
 }