我在authorize.net中使用了ARB,我使用php和Xml在ARB中请求创建订阅。它在本地工作正常,但我上传了服务器中的文件,显示以下错误,
错误消息:名称不能以''字符,十六进制值0x20开头。第1行,第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>";
答案 0 :(得分:0)
首先通过php trim()传递所有值,如
$firstName = trim($firstName) ;
$lastName = trim($lastName) ;
然后传递给您的表单 另外 - 这可能不适合你正在做的但想要传递 - 你可以使xml字符串没有像
那样的所有点连接 "<billTo>
<firstName>$firstName</firstName>
<lastName>$lastName</lastName>" ;
如果您使用php执行此操作 - php将处理双引号内的$变量并输出为文本值。
答案 1 :(得分:0)
最后我通过使用xml验证器获得了解决方案,我在$startdate
变量中犯了一个错误,它保存了日期函数,我还没有将<?php
标记添加到日期函数中。
通过使用<?php
,它解决了问题。感谢Cartalot的建议。