我需要连接到tnt expressconnect,获取我正在使用php的给定重量和体积的产品的定价详细信息,并尝试连接到PHP Post XML Request to server ( TNT Express Connect Pricing module)

<?php
/**
 *  Submit XML to the TNT
 *  server via a Stream instead
 *  of cURL.
 *
 *  @Returns String (XML)
**/

error_reporting(E_ALL);
ini_set('display_errors', 1);

function sendToTNTServer( $Xml ) {

$postdata = http_build_query(
                   array(
                     //For Future reference
                     //the xml_in= ( the = ) is appended
                     //Automatically by PHP
                    'xml_in' => $Xml
                   )
        );

$opts = array('http' =>
            array(
               'method'  => 'POST',
               'header'  => 'Content-type: application/x-www-form-urlencoded',
               'content' => $postdata
             )
         );

$context  = stream_context_create( $opts );
$output = file_get_contents(
       'https://express.tnt.com/expressconnect/pricing/getprice',
       false,
       $context
     );

     return $output;
}

$XmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
              <PRICEREQUEST>
                   <LOGIN>
                       <COMPANY>CITXXXXXX</COMPANY>
                       <PASSWORD>XXXXX</PASSWORD>
                       <APPID>PC</APPID>
                   </LOGIN>
                   <PRICECHECK>
                       <RATEID>rate1</RATEID>
                       <ORIGINCOUNTRY>AUD</ORIGINCOUNTRY>
                       <ORIGINTOWNNAME>Atherstone</ORIGINTOWNNAME>
                       <ORIGINPOSTCODE>CV9 2RY</ORIGINPOSTCODE>
                       <ORIGINTOWNGROUP/>
                       <DESTCOUNTRY>ES</DESTCOUNTRY>
                       <DESTTOWNNAME>Alicante</DESTTOWNNAME>
                       <DESTPOSTCODE>03006</DESTPOSTCODE>
                       <DESTTOWNGROUP/>
                       <CONTYPE>N</CONTYPE>
                       <CURRENCY>GBP</CURRENCY>
                       <WEIGHT>0.2</WEIGHT>
                       <VOLUME>0.1</VOLUME>
                       <ACCOUNT/>
                       <ITEMS>1</ITEMS>
                 </PRICECHECK>
            </PRICEREQUEST>";

$returnXml = sendToTNTServer( $XmlString );
    echo $returnXml;
?>

但这段代码给了我一个无法识别的登录详细信息错误

最佳答案

检查代码:将<ORIGINCOUNTRY>AUD更改为AU

             <PRICECHECK>
                   <RATEID>rate1</RATEID>
                   <ORIGINCOUNTRY>AU</ORIGINCOUNTRY>
                   <ORIGINTOWNNAME>Atherstone</ORIGINTOWNNAME>
                   <ORIGINPOSTCODE>CV9 2RY</ORIGINPOSTCODE>
                   <ORIGINTOWNGROUP/>
                   <DESTCOUNTRY>ES</DESTCOUNTRY>
                   <DESTTOWNNAME>Alicante</DESTTOWNNAME>
                   <DESTPOSTCODE>03006</DESTPOSTCODE>
                   <DESTTOWNGROUP/>
                   <CONTYPE>N</CONTYPE>
                   <CURRENCY>AUD</CURRENCY>
                   <WEIGHT>0.2</WEIGHT>
                   <VOLUME>0.1</VOLUME>
                   <ACCOUNT/>
                   <ITEMS>1</ITEMS>
             </PRICECHECK>

09-09 22:29