我发布值时得到的回复是20400Invalid Request1
。
根据文档
http://www.ballwin.mo.us/images/file/3%20Certifcation%20FAQ.pdf
13。为什么我收到“20400无效请求”错误? 这是Apache服务器错误,意味着“页面无法显示”。这通常 表示网关服务不可用。一旦你在生产 联系网关支持
我不明白错误代表什么
<?php
$url = "https://orbitalvar2.paymentech.net"; // testing
//$url = "https://orbital1.paymentech.net"; // production
$post_string="
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<Request>
<MarkForCapture>
<OrbitalConnectionUsername>*****</OrbitalConnectionUsername>
<OrbitalConnectionPassword>*****</OrbitalConnectionPassword>
<OrderID>123456782</OrderID>
<Amount>100</Amount>
<BIN>000002</BIN>
<MerchantID>**********</MerchantID>
<TerminalID>001</TerminalID>
<TxRefNum>4F320B79F23280DAE62777C80721F838FF13548D</TxRefNum>
</MarkForCapture>
</Request>";
$header= "POST /authorize/ HTTP/1.0\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-type: application/PTI53\r\n";
$header.= "Content-length: " .strlen($post_string) . "\r\n";
$header.= "Content-transfer-encoding: text\r\n";
$header.= "Request-number: 1\r\n";
$header.= "Document-type: Request\r\n";
$header.= "Interface-Version: Test 1.4\r\n";
$header.= "Connection: close \r\n\r\n";
$header.= $post_string;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
$data = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
}
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE,1);
xml_parse_into_struct($xml_parser, $data, $vals, $index);
xml_parser_free($xml_parser);
print ($data);
?>
Plesase帮助我。提前谢谢。
答案 0 :(得分:0)
我相信您收到此错误是因为您使用了错误的编码标头。
更改此行:
$header.= "Content-transfer-encoding: text\r\n";
要:
$header.= "Content-transfer-encoding: 8BIT\r\n";
这可能会解决您的问题。
如果没有,也尝试使用$ post_string上的utf8_encode()显式地将XML转换为UTF-8。