- function exactor_do_post_request($url, $data)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml'));
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_TIMEOUT, 30);
- $response = curl_exec($ch);
- curl_close($ch);
- return $response;
- }
- $URL = "https://taxrequest.exactor.com/request/xml";
- $xml = "<TaxRequest xmlns=/"http://www.exactor.com/ns/">";
- $xml .= "<MerchantId>" . htmlspecialchars($this->merchantID) . "</MerchantId>";
- $xml .= "<UserId>" . htmlspecialchars($this->userID) . "</UserId>";
- $xml .= "<RefundRequest>";
- $xml .= "<RefundDate>" . date("Y-m-d") . "</RefundDate>";
- $xml .= "<PriorTransactionId>".$transactionID."</PriorTransactionId>";
- $xml .= "</RefundRequest>";
- $xml .= "</TaxRequest>";
- $response = $this->exactor_do_post_request($URL, $xml);
- $parser = xml_parser_create();
- xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
- xml_parse_into_struct($parser, $response, $values, $tags);
- xml_parser_free($parser);
- $error_code = "";
- for ($i = 0; $i < count($values); $i++)
- {
- if ($values[$i]["tag"] == "ERRORCODE")
- {
- $error_code = $values[$i]["value"];
- break;
- }
- }
- if ($error_code != "")
- {
- return $this->exactor_error_handler($error_code);
- }
PHP curl_init Post 提交
最新推荐文章于 2024-09-12 14:46:15 发布