2013-06-11 94 views
0

我想这个问题不是Sage Pay的具体问题,虽然它被提及与我的问题有关,所以希望你能帮助我解决这个棘手的问题。从xml文件中读取(Sage Pay Reporting API)

这就是我想做的事:

  • 的主要任务是从圣人薪酬报告API获取数据 - 就像一个魅力
  • 阅读和收集从XML输出文件中的变量 - 不工作

下面的代码确实显示重定向到Sage Pay网站后的交易列表,但我无法弄清楚如何获得例如单个交易的金额并存储它。

这里是xml output的样子:

任何答案/解决方案?我感谢您的帮助!

<? 

$command = 'getTransactionList'; 
$vendor = 'vendorname'; 
$user = 'username'; 
$password = 'pwd'; 
$startdate = '01/05/2013 00:00:01'; 
$enddate = '31/05/2013 23:59:59'; 

$string = '<command>'.$command.'</command><vendor>'.$vendor.'</vendor><user>'.$user.'</user><startdate>'.$startdate.'</startdate><enddate>'.$enddate.'</enddate>'; 


$crypt = MD5($string . '<password>' . $password . '</password>'); 

$curl = curl_init('https://test.sagepay.com/access/access.htm'); 
curl_setopt($curl, CURLOPT_FAILONERROR, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
$result = curl_exec($curl); 

$rxml = simplexml_load_string($result); 
echo $rxml->transactions->transaction[0]->amount; 

?> 

<HTML> 

<BODY> 


<form method="post" action="https://test.sagepay.com/access/access.htm"> 

<input type="hidden" name="XML" value="<vspaccess><?php echo $string; ?><signature><?php echo $crypt; ?></signature></vspaccess>"> 
<input type="submit" name="Button" value="Send"> 

</form> 
</BODY> 
</HTML> 
+0

显示您在'$ result'中获得的XML(删除任何财务或个人数据)。 – MrCode

+0

如果你想分析XML,重要的不是你如何连接到外部计算机来下载数据,而是下载的XML数据如何(你不说)。 –

+0

谢谢MrCode和Álvaro。当我注意到我需要声望为10才能显示它时,我已经在我的发帖中输出了结果。将尝试其他方式... – Kleni

回答

1

替换$ RXML = simplexml_load_string($结果);

$ RXML =新SimpleXMLElement($结果);