<?php
$request = new HttpRequest();
$request->setUrl('https://api.ltl.xpo.com/rating/1.0/ratequotes');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'format' => 'XML'
));
$request->setHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/xml',
'authorization' => 'Bearer 5ce5e6e3304fd4e069b1c00f1c1f9bab'
));
$request->setBody('<?xml version="1.0" encoding="UTF-8"?>
<GetXpoLtlRateQuoteRqst xmlns="http://www.ltl.xpo.com/API/LTLRatingAPI">
<shipmentInfo>
<paymentTermCd>P</paymentTermCd>
<accessorials>
<accessorialCd>DNC</accessorialCd>
<accessorialCd>GUR</accessorialCd>
</accessorials>
<commodity>
<grossWeight>
<weight>500</weight>
<weightUom>lbs</weightUom>
</grossWeight>
<nmfcClass>100</nmfcClass>
<hazmatInd>false</hazmatInd>
</commodity>
<shipmentDate>2018-11-19</shipmentDate>
<shipper>
<address>
<acctInstId>117258878</acctInstId>
<postalCd>93727</postalCd>
</address>
</shipper>
<consignee>
<address>
<postalCd>92027</postalCd>
</address>
</consignee>
</shipmentInfo>
</GetXpoLtlRateQuoteRqst>
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
<?php
require 'HttpRequest.php';
$request = new HttpRequest();
$request->setUrl('https://api.ltl.xpo.com/rating/1.0/ratequotes');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'format' => 'XML'
));
$request->setHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/xml',
'authorization' => 'Bearer 5ce5e6e3304fd4e069b1c00f1c1f9bab'
));
$request->setBody('<?xml version="1.0" encoding="UTF-8"?>
<GetXpoLtlRateQuoteRqst xmlns="http://www.ltl.xpo.com/API/LTLRatingAPI">
<shipmentInfo>
<paymentTermCd>P</paymentTermCd>
<accessorials>
<accessorialCd>DNC</accessorialCd>
<accessorialCd>GUR</accessorialCd>
</accessorials>
<commodity>
<grossWeight>
<weight>500</weight>
<weightUom>lbs</weightUom>
</grossWeight>
<nmfcClass>100</nmfcClass>
<hazmatInd>false</hazmatInd>
</commodity>
<shipmentDate>2018-11-19</shipmentDate>
<shipper>
<address>
<acctInstId>117258878</acctInstId>
<postalCd>93727</postalCd>
</address>
</shipper>
<consignee>
<address>
<postalCd>92027</postalCd>
</address>
</consignee>
</shipmentInfo>
</GetXpoLtlRateQuoteRqst>
');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
$strData = '<?xml version="1.0" encoding="UTF-8"?>
<GetXpoLtlRateQuoteRqst xmlns="http://www.ltl.xpo.com/API/LTLRatingAPI">
<shipmentInfo>
...etc...
</shipmentInfo>
</GetXpoLtlRateQuoteRqst>';
$ch = curl_init('https://api.ltl.xpo.com/rating/1.0/ratequotes');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $strData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/xml',
'cache-control' => 'no-cache',
'authorization' => 'Bearer 5ce5e6e3304fd4e069b1c00f1c1f9bab',
'Content-Length: ' . strlen($strData)));
$result = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
echo $result;
There are also auto-class loaders that will load up the right file if the class doesn't exist yet (you just tell the loader where to look for the class files).