- 论坛徽章:
- 0
|
php 使用 curl post xml data 时候,老是被对断认为是,畸形xml
下面是简单的php 程序和 xml data 文件
对端是 http://p-p-g.net/gateway_v2.php
返回结果是
malformed XML input(XML_Parser: no element found at XML input line 1)
<?php
$XPost = file("xml.xml");
foreach($XPost as $k=>$v)
{
$t.=trim($v);
}
$XPost=$t;
$url = "http://p-p-g.net/gateway_v2.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
//curl_setopt($ch,CURLOPT_BINARYTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost);
$result = curl_exec($ch);
echo $result;
?>
xml.xml
<?xml version="1.0" encoding="utf-8" ?>
<epxml>
<header>
<responsetype>direct</responsetype>
<mid>2</mid>
<password>test</password>
<type>charge</type>
</header>
<request>
<charge>
<etan>1231454543</etan>
<card>
<cctype>visa</cctype>
<cc>4906383347771203</cc>
<expire>12/06</expire>
<cvv>688</cvv>
</card>
<cardholder>
<name>John</name>
<surname>Doe</surname>
<street>Anystreet</street>
<housenumber>12</housenumber>
<zip>12345</zip>
<city>anytown</city>
<country>US</country>
<state>NY</state>
<email>any@emailaddress.com</email>
</cardholder>
<amount>
<currency>EUR</currency>
<value>123</value>
</amount>
<product>
<name>anyp</name>
<url>http://any-url.com</url>
</product>
</charge>
</request>
</epxml> |
|