public function getGeneratedXML() { $dom = new XmlDomConstruct('1.0', 'utf-8'); $dom->fromMixed(array('request' => $this->_args)); $post_data = $dom->saveXML(); $post_data = str_replace('<request/>', '<request method="' . $this->_method . '" />', $post_data); $post_data = str_replace('<request>', '<request method="' . $this->_method . '">', $post_data); return $post_data; }
protected static function _makeRequest() { self::_buildRequest(); // function call to convert array to xml $dom = new XmlDomConstruct('1.0', 'utf-8'); $req = array('Request' => self::$_final_request); $dom->fromMixed($req); $post_data = $dom->saveXML(); // If we're debugging, just return what we were going to send to the server if (self::$debug) { return $post_data; } $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL, PSIGATE_URL); // set url to post to curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 40); // times out after 40s curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); // add POST fields // You should normally leave this on. But I'll assume you know what you're doing ;) if (defined('PSIGATE_DISABLE_SSL') && PSIGATE_DISABLE_SSL === true) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } $result = curl_exec($ch); if (curl_errno($ch)) { throw new PsigateAccountManagerException('A cURL error occured: ' . curl_error($ch)); } else { curl_close($ch); } $response = json_decode(json_encode(simplexml_load_string($result)), true); // Reset self::$_request = array(); return $response; }
public function getGeneratedXML() { $dom = new XmlDomConstruct('1.0', 'utf-8'); $dom->fromMixed($this->_args); $post_data = $dom->saveXML(); return $post_data; }