/** * Parse a response from Borica. * * @param string $message * @return Response */ public function response($message = null) { if (!empty($message)) { return $this->response->parse($message); } return $this->response; }
/** * @return Response * @throws \Exception */ public function send() { $this->xmlStr = self::generateXML(); $ch = curl_init(); //initiate the curl session curl_setopt($ch, CURLOPT_TIMEOUT, 40); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_URL, 'https://' . $this->ADRIPAddress . ":" . $this->ADRPort); //set to url to post to curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // tell curl to return data in a variable; curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, 'OrderXml=' . $this->xmlStr); // post the xml $xmlResponse = curl_exec($ch); if (!$xmlResponse) { throw new \Exception('Unable to connect to ADR: ' . curl_error($ch)); } curl_close($ch); $response = new Response(); $response->loadXML($xmlResponse); $response->parse(); //Let's check for any errors if ($response->getError() != '0') { throw new \Exception('ADR ERROR: ' . $response->getError() . ' ' . $response->getErrorDescription() . PHP_EOL); } return $response; }
public function post($url, $params) { // Removing all 'null' values to reduce parameters sendt. foreach ($params as $key => $value) { if ($value == null) { unset($params[$key]); } } $params['api_secret'] = $this->config->apiSecret; $params = 'enc_request=' . urlencode($this->_encrypt($params)) . '&appID=' . $this->config->appId . '&v=2.0&s=php'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->config->endpoint . $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Cert' . DIRECTORY_SEPARATOR . 'ip_gd_bundle.crt'); curl_setopt($ch, CURLOPT_MAXREDIRS, 3); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_SSLVERSION, 0); $response = new Response(); $response->rawResponse = curl_exec($ch); $response->httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $response->parse(); curl_close($ch); //If the session option is not set, close the session. return $response; }
/** * Submit the current API call, and unmarshalls the result into PHP objects. * * @return \Prismic\Response the result of the call * * @throws \RuntimeException */ public function submit() { return Response::parse($this->submit_raw()); }
/** * Return the Response instance. * * @param string $raw * @return \Axado\Response */ protected function createResponse($raw) { $response = new Response(); $response->parse($raw); return $response; }