[英]UPS API using cURL and PHP…well-formed XML issue
UPS服務器不斷給我以下響應:
HTTP/1.1 200 OK
Server: Apache
Content-Length: 429
X-Powered-By: Servlet/2.5 JSP/2.1
Content-Type: application/xml
Expires: Wed, 31 Aug 2011 21:28:12 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Wed, 31 Aug 2011 21:28:12 GMT
Connection: keep-alive
出現此錯誤:
<AddressValidationResponse>
<Response>
<TransactionReference>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<ResponseStatusCode>0</ResponseStatusCode>
<ResponseStatusDescription>Failure</ResponseStatusDescription>
<Error>
<ErrorSeverity>Hard</ErrorSeverity>
<ErrorCode>10001</ErrorCode>
<ErrorDescription>The XML document is not well formed</ErrorDescription>
</Error>
</Response>
</AddressValidationResponse>
這是我要發送到服務器的PHP代碼。 是否有我遺漏並忽略的錯誤?
$data = '<?xml version=\"1.0\" ?>
<AccessRequest xml:lang=\"en-US\">
<AccessLicenseNumber>$this->AccessLicenseNumber</AccessLicenseNumber>
<UserId>$this->UserId</UserId>
<Password>$this->Password</Password>
</AccessRequest>
<?xml version=\"1.0\" ?>
<AddressValidationRequest xml:lang=\"en-US\">
<Request>
<TransactionReference>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>XAV</RequestAction>
<RequestOption>3</RequestOption>
</Request>
<AddressKeyFormat>
<AddressLine>$address</AddressLine>
<PoliticalDivision2>$city</PoliticalDivision2>
<PoliticalDivision1>$state</PoliticalDivision1>
<PostcodePrimaryLow>$zip</PostcodePrimaryLow>
<CountryCode>US</CountryCode>
</AddressKeyFormat>
</AddressValidationRequest>';
任何幫助將不勝感激。 謝謝。
您必須使用"
而不是'
來包裝xml,如下所示:
$data="<?xml...";
PHP僅替換"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.