我在authorize.net中使用了ARB,我使用php和Xml来请求在ARB中创建订阅。它在本地工作正常,但我在服务器上上传的文件显示以下错误,
错误信息:名称不能以' '字符开头,十六进制值0x20。第一行,位置406.
错误码: E00003
谁能建议如何解决这个问题,我是否必须联系服务器?
下面是我用来请求的Xml文件,
$content ="<?xml version='"1.0'" encoding='"utf-8'"?>" .
"<ARBCreateSubscriptionRequest xmlns='"AnetApi/xml/v1/schema/AnetApiSchema.xsd'">" .
"<merchantAuthentication>".
"<name>5A3RXdSct55</name>".
"<transactionKey>" . $transactionkey . "</transactionKey>".
"</merchantAuthentication>".
"<refId>" .$refId . "</refId>".
"<subscription>".
"<name>Monthly Subscription</name>".
"<paymentSchedule>".
"<interval>".
"<length>". $length ."</length>".
"<unit>". $unit ."</unit>".
"</interval>".
"<startDate>" . $startDate . "</startDate>".
"<totalOccurrences>". $totalOccurrences . "</totalOccurrences>".
"<trialOccurrences>". $trialOccurrences . "</trialOccurrences>".
"</paymentSchedule>".
"<amount>". $amount ."</amount>".
"<trialAmount>" . $trialAmount . "</trialAmount>".
"<payment>".
"<creditCard>".
"<cardNumber>" . $cardNumber . "</cardNumber>".
"<expirationDate>" . $expirationDate . "</expirationDate>".
"</creditCard>".
"</payment>".
"<billTo>".
"<firstName>". $firstName . "</firstName>".
"<lastName>" . $lastName . "</lastName>".
"<company>" . $company . "</company>".
"<address>" . $address . "</address>".
"<city>" . $city . "</city>".
"<state>" . $state . "</state>".
"<zip>" . $zipcode . "</zip>".
"<country>" . $country . "</country>".
"</billTo>".
"<shipTo>".
"<firstName>". $firstName . "</firstName>".
"<lastName>" . $lastName . "</lastName>".
"<company>" . $company . "</company>".
"<address>" . $address . "</address>".
"<city>" . $city . "</city>".
"<state>" . $state . "</state>".
"<zip>" . $zipcode . "</zip>".
"<country>" . $country . "</country>".
"</shipTo>".
"</subscription>".
"</ARBCreateSubscriptionRequest>";
首先通过PHP trim()传递所有值,如
$firstName = trim($firstName) ;
$lastName = trim($lastName) ;
然后传递给表单此外——这可能不适合你正在做的事情,但想传递——你可以使xml字符串没有所有的点连接,如
"<billTo>
<firstName>$firstName</firstName>
<lastName>$lastName</lastName>" ;
如果你用PHP这样做- PHP将处理双引号内的$变量,并作为文本值输出。
最后我通过使用xml验证器得到了解决方案,我在$startdate
变量中犯了一个错误,它包含日期函数,我没有将<?php
标签添加到日期函数。
用<?php
解决了这个问题。谢谢你的建议,cartalot。